ALICE 1.3  1.0
Develpoer documentation
alice-desktop-1.3.pyw
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: cp1252 -*-
3 #
4 # ADALM1000 alice-desktop 1.3.py(w) (8-20-2021)
5 # For Python version 2.7 or 3.7, Windows OS and Linux OS
6 # With external module pysmu ( libsmu >= 1.0.2 for ADALM1000 )
7 # optional split I/O modes for Rev F hardware supported
8 # Uses new firmware (2.17 or >) that support control of ADC mux configure
9 # Created by D Mercer ()
10 #
11 #
12 import __future__
13 import math
14 import time
15 try:
16  import numpy
17  numpy_found = True
18 except:
19  numpy_found = False
20 #
21 # If runing from source you can un-comment the following to include pyplot
22 try:
23  from matplotlib import pyplot as plt
24  matplot_found = True
25 except:
26  matplot_found = False
27 #
28 import csv
29 import wave
30 import os
31 #import requests
32 import sys
33 import struct
34 import subprocess
35 from time import gmtime, strftime
36 # Check to see if user passed init file name on command line
37 if len(sys.argv) > 1:
38  InitFileName = str(sys.argv[1])
39  print( 'Init file name: ' + InitFileName )
40 else:
41  InitFileName = 'alice_init.ini'
42 
43 if sys.version_info[0] == 2:
44  print ("Python 2.x")
45  import urllib2
46  import tkFont
47  from Tkinter import *
48  from ttk import *
49  from tkFileDialog import askopenfilename
50  from tkFileDialog import asksaveasfilename
51  from tkSimpleDialog import askstring
52  from tkMessageBox import *
53 if sys.version_info[0] == 3:
54  print ("Python 3.x")
55  import urllib.request, urllib.error, urllib.parse
56  from tkinter.font import *
57  from tkinter import *
58  from tkinter.ttk import *
59  from tkinter.filedialog import askopenfilename
60  from tkinter.filedialog import asksaveasfilename
61  from tkinter.simpledialog import askstring
62  from tkinter.messagebox import *
63 #
64 import webbrowser
65 try:
66  from pysmu import *
67  pysmu_found = True
68 except:
69  pysmu_found = False
70 #
71 # check which operating system
72 import platform
73 #
74 RevDate = "20 Aug 2021"
75 SWRev = "1.3 "
76 Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.11/alice-desktop-1.3-setup.exe'
77 # small bit map of ADI logo for window icon
78 TBicon = """
79 R0lGODlhIAAgAHAAACH5BAEAAAIALAAAAAAgACAAgQAAAP///wAAAAAAAAJJhI+py+0PYwtBWkDp
80 hTnv2XlfEobjUZZnmn4se72vJMtcbYN4ruz44uORgiodsfI4Im++2M5VW81OmBbVULxiRVrUsgsO
81 i8fUAgA7
82 """
83 
84 root=Tk()
85 root.title("ALICE DeskTop " + SWRev + RevDate + ": ALM1000 Oscilloscope")
86 img = PhotoImage(data=TBicon)
87 root.call('wm', 'iconphoto', root._w, '-default', img)
88 print("Windowing System is " + str(root.tk.call('tk', 'windowingsystem')))
89 
90 GRW = 720 # Width of the time grid 720 default
91 GRH = 390 # Height of the time grid 390 default
92 X0L = 55 # Left top X value of time grid
93 Y0T = 25 # Left top Y value of time grid
94 #
95 GRWF = 720 # Width of the spectrum grid 720 default
96 GRHF = 390 # Height of the spectrum grid 390 default
97 X0LF = 45 # Left top X value of spectrum grid
98 Y0TF = 25 # Left top Y value of spectrum grid
99 #
100 GRWBP = 720 # Width of the Bode Plot grid 720 default
101 GRHBP = 390 # Height of the Bode Plot grid 390 default
102 X0LBP = 45 # Left top X value of Bode Plot grid
103 Y0TBP = 25 # Left top Y value of Bode Plot grid
104 #
105 GRWXY = 420 # Width of the XY grid 420 default
106 GRHXY = 390 # Height of the XY grid 390 default
107 X0LXY = 55 # Left top X value of XY grid
108 Y0TXY = 25 # Left top Y value of XY grid
109 #
110 GRWIA = 400 # Width of the grid 400 default
111 GRHIA = 400 # Height of the grid 400 default
112 X0LIA = 37 # Left top X value of grid
113 Y0TIA = 25 # Left top Y value of grid
114 #
115 GRWNqP = 400 # Width of the Nyquist plot grid 400 default
116 GRHNqP = 400 # Height of the grid 400 default
117 X0LNqP = 25 # Left top X value of grid
118 Y0TNqP = 25 # Left top Y value of grid
119 #
120 GRWNiC = 400 # Width of the Nichols plot grid 400 default
121 GRHNiC = 400 # Height of the grid 400 default
122 X0LNiC = 25 # Left top X value of grid
123 Y0TNiC = 25 # Left top Y value of grid
124 #
125 GRWPhA = 400 # Width of the grid 400 default
126 GRHPhA = 400 # Height of the grid 400 default
127 X0LPhA = 37 # Left top X value of grid
128 Y0TPhA = 25 # Left top Y value of grid
129 #
130 FontSize = 8
131 BorderSize = 1
132 MouseX = MouseY = -10
133 MouseCAV = MouseCAI = MouseCBV = MouseCBI = MouseMuxA = MouseMuxB = MouseMuxC = MouseMuxD = -10
134 
135 COLORframes = "#000080" # Color = "#rrggbb" rr=red gg=green bb=blue, Hexadecimal values 00 - ff
136 COLORcanvas = "#000000" # 100% black
137 COLORgrid = "#808080" # 50% Gray
138 COLORzeroline = "#0000ff" # 100% blue
139 COLORtrace1 = "#00ff00" # 100% green
140 COLORtrace2 = "#ff8000" # 100% orange
141 COLORtrace3 = "#00ffff" # 100% cyan
142 COLORtrace4 = "#ffff00" # 100% yellow
143 COLORtrace5 = "#ff00ff" # 100% magenta
144 COLORtrace6 = "#C80000" # 90% red
145 COLORtrace7 = "#8080ff" # 100% purple
146 COLORtraceR1 = "#008000" # 50% green
147 COLORtraceR2 = "#905000" # 50% orange
148 COLORtraceR3 = "#008080" # 50% cyan
149 COLORtraceR4 = "#808000" # 50% yellow
150 COLORtraceR5 = "#800080" # 50% magenta
151 COLORtraceR6 = "#800000" # 80% red
152 COLORtraceR7 = "#4040a0" # 80% purple
153 COLORtext = "#ffffff" # 100% white
154 COLORtrigger = "#ff0000" # 100% red
155 COLORsignalband = "#ff0000" # 100% red
156 ButtonGreen = "#00ff00" # 100% green
157 ButtonRed = "#ff0000" # 100% red
158 GUITheme = "Light"
159 ButtonOrder = 0
160 SBoxarrow = 11
161 Closed = 0
162 ColorMode = IntVar(0)
163 # # Can be Light or Dark or Blue or LtBlue or Custom where:
164 FrameBG = "#d7d7d7" # Background color for frame
165 ButtonText = "#000000" # Button Text color
166 # Widget relief can be RAISED, GROOVE, RIDGE, and FLAT
167 ButRelief = RAISED
168 LabRelief = FLAT
169 FrameRefief = RIDGE
170 LocalLanguage = "English"
171 
172 OnBoardRes = 50.83
173 AD584act = 2.5
174 # Set sample buffer size
175 HoldOff = 0.0
176 LShift = 0
177 BaseSampleRate = 100000
178 AWGSAMPLErate = BaseSampleRate # Sample rate of the AWG channels
179 SAMPLErate = BaseSampleRate # Scope sample rate can be decimated
180 MinSamples = 2000
181 MaxSamples = 200000
182 ETSrecord = 2000
183 AWGRecLength = 32768
184 DISsamples = GRW
185 First_Slow_sweep = 0
186 Slow_Sweep_Limit = 200
187 # set initial trigger conditions
188 TRIGGERlevel = 2.5 # Triggerlevel in volts
189 
190 MathString = "VBuffA[t] + VBuffB[t]"
191 MathUnits = " V"
192 MathXString = "VBuffA[t]"
193 MathXUnits = " V"
194 MathYString = "VBuffB[t]"
195 MathYUnits = " V"
196 UserAString = "MaxV1-VATop"
197 UserALabel = "OverShoot"
198 UserBString = "MinV2-VBBase"
199 UserBLabel = "UnderShoot"
200 MathAxis = "V-A"
201 MathXAxis = "V-A"
202 MathYAxis = "V-B"
203 AWGAMathString = "(VBuffA + VBuffB)/2"
204 AWGBMathString = "(VBuffA + VBuffB)/2"
205 AWGAcsvFile = "examplea.csv"
206 AWGBcsvFile = "exampleb.csv"
207 AWGAwavFile = "examplea.wav"
208 AWGBwavFile = "exampleb.wav"
209 FFTUserWindowString = "numpy.kaiser(SMPfft, 14) * 3"
210 DigFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
211 DigFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
212 AWGFilterAString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
213 AWGFilterBString = "numpy.sinc(numpy.linspace(-1, 1, 91))"
214 ChaMeasString1 = "DCV1"
215 ChaMeasString2 = "DCI1"
216 ChaMeasString3 = "SV1"
217 ChaMeasString4 = "MaxV1-MinV1"
218 ChaMeasString5 = "MaxI1-MinI1"
219 ChaMeasString6 = "math.sqrt(SV1**2 - DCV1**2)"
220 ChbMeasString1 = "DCV2"
221 ChbMeasString2 = "DCI2"
222 ChbMeasString3 = "SV2"
223 ChbMeasString4 = "MaxV2-MinV2"
224 ChbMeasString5 = "MaxI2-MinI2"
225 ChbMeasString6 = "math.sqrt(SV2**2 - DCV2**2)"
226 ChaLableSrring1 = "CHA-DCV "
227 ChaLableSrring2 = "CHA-DCI "
228 ChaLableSrring3 = "CHA-TRMS "
229 ChaLableSrring4 = "CHA-VP-P "
230 ChaLableSrring5 = "CHA-IP-P "
231 ChaLableSrring6 = "CHA-ACRMS "
232 ChbLableSrring1 = "CHB-DCV "
233 ChbLableSrring2 = "CHB-DCI "
234 ChbLableSrring3 = "CHB-TRMS "
235 ChbLableSrring4 = "CHB-VP-P "
236 ChbLableSrring5 = "CHB-IP-P "
237 ChbLableSrring6 = "CHB-ACRMS "
238 LabelPlotText = IntVar(0)
239 PlotLabelText = "Custom Plot Label"
240 
241 GridWidth = IntVar(0)
242 GridWidth.set(1)
243 TRACEwidth = IntVar(0)
244 TRACEwidth.set(1)
245 TRACEaverage = IntVar(0) # Number of average sweeps for average mode
246 TRACEaverage.set(8)
247 Vdiv = IntVar(0)
248 Vdiv.set(10) # Number of vertical divisions for spectrum / Bode
249 LPFTrigger = IntVar(0) # trigger lpf on/off
250 Trigger_LPF_length = IntVar(0)
251 Trigger_LPF_length.set(10) # Length of Trigger box car LPF in samples
252 HarmonicMarkers = IntVar(0)
253 HarmonicMarkers.set(3)
254 AWGShowAdvanced = IntVar(0)
255 AWGShowAdvanced.set(0)
256 AWG_Amp_Mode = IntVar(0)
257 AWG_Amp_Mode.set(0) # 0 = Min/Max mode, 1 = Amp/Offset
258 AWGA_Ext_Gain = DoubleVar(0)
259 AWGA_Ext_Gain.set(1.0)
260 AWGA_Ext_Offset = DoubleVar(0)
261 AWGA_Ext_Offset.set(0.0)
262 AWGB_Ext_Gain = DoubleVar(0)
263 AWGB_Ext_Gain.set(1.0)
264 AWGB_Ext_Offset = DoubleVar(0)
265 AWGB_Ext_Offset.set(0.0)
266 AWG_2X = IntVar(0) # selection variable to set AWG DAC channes for 2X samplerate modes
267 Two_X_Sample = IntVar(0) # selection variable to set ADC channes for 2X samplerate mode
268 Two_X_Sample.set(0)
269 ADC_Mux_Mode = IntVar(0) # selection variable to set ADC CHA for voltagr or current 2X samplerate mode
270 ADC_Mux_Mode.set(0)
271 Last_ADC_Mux_Mode = 0
272 Alternate_Sweep_Mode = IntVar(0) # alternate sweeps when in 2X samplerate mode
273 Alternate_Sweep_Mode.set(0)
274 #
275 ChopModeFilter = [0.25, 0.25, 0.25, 0.25] # [0.25, 0.25, 0.25, 0.25]
276 # ChopModeFilter = [0, 1, 2, 3, 4, 3, 2, 1, 0]
277 # ChopModeFilter = numpy.array(ChopModeFilter) / 16
278 Roll_Mode = IntVar(0) # select roll sweep (slow) mode
279 Roll_Mode.set(0)
280 #
281 ZEROstuffing = IntVar(0) # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
282 ZEROstuffing.set(1)
283 FFTwindow = IntVar(0) # FFT window function variable
284 FFTwindow.set(5) # FFTwindow 0=None (rectangular B=1), 1=Cosine (B=1.24), 2=Triangular non-zero endpoints (B=1.33),
285  # 3=Hann (B=1.5), 4=Blackman (B=1.73), 5=Nuttall (B=2.02), 6=Flat top (B=3.77)
286 RelPhaseCorrection = 15 # Relative Phase error seems to be a random number each time board is powered up
287 RelPhaseCenter = IntVar(0)
288 RelPhaseCenter.set(0) # Center line value for phase plots
289 ImpedanceCenter = IntVar(0)
290 ImpedanceCenter.set(0) # Center line value for impedance plots
291 MultipleBoards = IntVar(0)
292 MultipleBoards.set(0) # Turn on access for multiple m1k boards
293 IgnoreFirmwareCheck = 0
294 EnableScopeOnly = 0
295 EnableXYPlotter = 1
296 EnablePhaseAnalizer = 1
297 EnableSpectrumAnalizer = 1
298 EnableBodePlotter = 1
299 EnableImpedanceAnalizer = 1
300 EnableOhmMeter = 1
301 EnableDigIO = 1
302 EnableCommandInterface = 0
303 EnableMuxMode = 0
304 EnablePIODACMode = 0
305 EnableMinigenMode = 0
306 EnablePmodDA1Mode = 0
307 EnableDigPotMode = 0
308 EnableGenericSerialMode = 0
309 EnableAD5626SerialMode = 0
310 EnableDigitalFilter = 0
311 EnableMeasureScreen = 0
312 EnableETSScreen = 0
313 EnableHSsampling = 0
314 EnableUserEntries = 0
315 AllowFlashFirmware = 0
316 DeBugMode = 0
317 ShowTraceControls = 0
318 # ADC Mux defaults
319 v1_adc_conf = 0x20F1
320 i1_adc_conf = 0x20F7
321 v2_adc_conf = 0x20F7
322 i2_adc_conf = 0x20F1
323 #
324 MouseFocus = 1
325 HistAsPercent = 0
326 ShowBallonHelp = 0
327 contloop = 0
328 discontloop = 0
329 AwgLayout = "Horz"
330 MarkerLoc = 'UL' # can be UL, UR, LL or LR
331 CHA_TC1 = DoubleVar(0)
332 CHA_TC1.set(1)
333 CHA_TC2 = DoubleVar(0)
334 CHA_TC2.set(1)
335 CHB_TC1 = DoubleVar(0)
336 CHB_TC1.set(1)
337 CHB_TC2 = DoubleVar(0)
338 CHB_TC2.set(1)
339 CHA_A1 = DoubleVar(0)
340 CHA_A1.set(1)
341 CHA_A2 = DoubleVar(0)
342 CHA_A2.set(1)
343 CHB_A1 = DoubleVar(0)
344 CHB_A1.set(1)
345 CHB_A2 = DoubleVar(0)
346 CHB_A2.set(1)
347 Auto_ETS_Comp = IntVar(0)
348 ETS_TC1 = DoubleVar(0)
349 ETS_TC1.set(0.18333)
350 ETS_A1 = DoubleVar(0)
351 ETS_A1.set(5.0)
352 ETS_TC2 = DoubleVar(0)
353 ETS_TC2.set(0.03)
354 ETS_A2 = DoubleVar(0)
355 ETS_A2.set(5.0)
356 PhaseOffset1x = 37
357 PhaseOffset2x = 37
358 #('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
359 # 'aqua' built-in native Mac OS X only; Native Mac OS X
360 windowingsystem = root.tk.call('tk', 'windowingsystem')
361 ScreenWidth = root.winfo_screenwidth()
362 ScreenHeight = root.winfo_screenheight()
363 # print(str(ScreenWidth) + "X" + str(ScreenHeight))
364 if (root.tk.call('tk', 'windowingsystem')=='aqua'):
365  Style_String = 'aqua'
366  # On Macs, allow the dock icon to deiconify.
367  root.createcommand('::tk::mac::ReopenApplication', root.deiconify)
368  root.createcommand('::tk::mac::Quit', root.destroy)# Bcloseexit)
369  # On Macs, set up menu bar to be minimal.
370  root.option_add('*tearOff', False)
371  if sys.version_info[0] == 2:
372  menubar = tKinter.Menu(root)
373  appmenu = tKinter.Menu(menubar, name='apple')
374  else:
375  menubar = tkinter.Menu(root)
376  appmenu = tkinter.Menu(menubar, name='apple')
377  # menubar = tk.Menu(root)
378  # appmenu = tk.Menu(menubar, name='apple')
379  menubar.add_cascade(menu=appmenu)
380  # appmenu.add_command(label='Exit', command=Bcloseexit)
381  root['menu'] = menubar
382 else:
383  Style_String = 'alt'
384 # Check if there is an alice_init.ini file to read in
385 try:
386  import alice
387  import pathlib
388 # pathlib only available as standard in Python 3.4 and higher. For Python 2.7 must manually install package
389  path = pathlib.Path(alice.__file__).parent.absolute()
390  filename = os.path.join(path, "resources", InitFileName) # "alice_init.ini")
391  InitFile = open(filename)
392  for line in InitFile:
393  try:
394  exec( line.rstrip(), globals(), globals())
395  #exec( line.rstrip() )
396  except:
397  print("Skiping " + line.rstrip())
398  InitFile.close()
399 except:
400  try:
401  InitFile = open(InitFileName) # "alice_init.ini"
402  for line in InitFile:
403  try:
404  exec( line.rstrip(), globals(), globals())
405  #exec( line.rstrip() )
406  except:
407  print("Skiping " + line.rstrip())
408  InitFile.close()
409  except:
410  print( "No Init File Read. " + InitFileName + " Not Found")
411 #
412 XOLXY = X0L = FontSize * 7
413 XOLF = XOLBP = XOLIA = int(FontSize * 4.625)
414 XOLNqP = XOLNiC = int(FontSize * 3.125)
415 root.style = Style()
416 try:
417  root.style.theme_use(Style_String)
418 except:
419  root.style.theme_use('default')
420 if MouseFocus == 1:
421  root.tk_focusFollowsMouse()
422 #
423 DevID = "m1k"
424 #
425 if sys.version_info[0] == 2:
426  default_font = tkFont.nametofont("TkDefaultFont")
427 if sys.version_info[0] == 3:
428  default_font = tkinter.font.nametofont("TkDefaultFont")
429 default_font.configure(size=FontSize)
430 
431 CHvpdiv = (0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0)
432 
433 CHipdiv = (0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
434 
435 SAMagdiv = ("10nV", "100nV", "1uV", "10uV", "100uV", "1mV", "10mV", "0.1", "1.0", "10.0")
436 
437 TMpdiv = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0)
438 ResScalediv = (1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000)
439 SampRateList = (1024, 2048, 4096, 8192, 16384, 32765, 64000, 93023, 93385, 93750, 94118,
440  96385, 96774, 97166, 97561, 97959, 98361, 98765, 99174, 99585, 100000)
441 NoiseList =[ "None", "Uniform", "Gaussian"]
442 TIMEdiv = 0.5
443 RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
444 
445 
446 AWGAAmplvalue = 0.0
447 AWGAOffsetvalue = 0.0
448 AWGAFreqvalue = 0.0
449 AWGAPhasevalue = 0
450 AWGAdelayvalue = 0
451 AWGADutyCyclevalue = 50
452 AWGAWave = 'dc'
453 AWGBAmplvalue = 0.0
454 AWGBOffsetvalue = 0.0
455 AWGBFreqvalue = 0.0
456 AWGBPhasevalue = 0
457 AWGBdelayvalue = 0
458 AWGBDutyCyclevalue = 50
459 AWGBWave = 'dc'
460 AWGACycles = 1
461 AWGBCycles = 1
462 AWGABurstDelay = 0
463 AWGBBurstDelay = 0
464 Reset_Freq = 300
465 MeasGateLeft = 0.0
466 MeasGateRight = 0.0 # in mSec
467 MeasGateNum = 0
468 MeasGateStatus = IntVar(0)
469 MeasGateStatus.set(0)
470 #
471 DCV1 = DCV2 = MinV1 = MaxV1 = MinV2 = MaxV2 = MidV1 = PPV1 = MidV2 = PPV2 = SV1 = SI1 = 0
472 
473 DCVMuxA = MinVMuxA = MaxVMuxA = MidVMuxA = PPVMuxA = SVMuxA = 0
474 DCVMuxB = MinVMuxB = MaxVMuxB = MidVMuxB = PPVMuxB = SVMuxB = 0
475 DCVMuxC = MinVMuxC = MaxVMuxC = MidVMuxC = PPVMuxC = SVMuxC = 0
476 DCVMuxD = MinVMuxD = MaxVMuxD = MidVMuxD = PPVMuxD = SVMuxD = 0
477 PeakVA = PeakVB = PeakIA = PeakIB = 0.0
478 PeakVMA = PeakVMB = PeakVMC = PeakVMD = 0.0
479 PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
480 PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = 0.0
481 PeakphaseVA = PeakphaseVB = PeakphaseIA = PeakphaseIB = PeakphaseVAB = 0.0
482 CHADCy = CHBDCy = 0
483 DCI1 = DCI2 = MinI1 = MaxI1 = MinI2 = MaxI2 = MidI1 = PPI1 = MidI2 = PPI2 = SV2 = SI2 = 0
484 CHAperiod = CHAfreq = CHBperiod = CHBfreq = 0
485 # Calibration coefficients
486 CHAVGain = CHBVGain = 1.0
487 CHAVOffset = CHBVOffset = 0.0
488 # Initialisation of general variables
489 CHAOffset = CHBOffset = CHBAOffset = CHBBOffset = CHBCOffset = CHBDOffset = 2.5
490 CHAIOffset = CHBIOffset = InOffA = InGainA = InOffB = InGainB = 0.0
491 # Other global variables required in various routines
492 CANVASwidth = GRW + 2 * X0L # The canvas width
493 CANVASheight = GRH + Y0T + (FontSize * 7) # The canvas height
494 
495 ADsignal1 = [] # Ain signal array channel A and B
496 VBuffA = []
497 VBuffB = []
498 IBuffA = []
499 IBuffB = []
500 VBuffMA = []
501 VBuffMB = []
502 VBuffMC = []
503 VBuffMD = []
504 VmemoryMuxA = []
505 VmemoryMuxB = []
506 VmemoryMuxC = []
507 VmemoryMuxD = []
508 #
509 DBuff0 = []
510 DBuff1 = []
511 DBuff2 = []
512 DBuff3 = []
513 #
514 VAresult = []
515 VBresult = []
516 IAresult = []
517 IBresult = []
518 PhaseIA = []
519 PhaseIB = []
520 PhaseVA = []
521 PhaseVB = []
522 DFiltACoef = [1]
523 DFiltBCoef = [1]
524 DigFiltA = IntVar(0)
525 DigFiltA.set(0)
526 DigFiltABoxCar = IntVar(0)
527 DigFiltBBoxCar = IntVar(0)
528 DigDeSkewA = IntVar(0)
529 DigDeSkewB = IntVar(0)
530 DigFiltB = IntVar(0)
531 DigFiltB.set(0)
532 DigBuffA = IntVar(0)
533 DigBuffB = IntVar(0)
534 DigBuffA.set(0)
535 DigBuffB.set(0)
536 AWGFiltA = IntVar(0)
537 AWGFiltB = IntVar(0)
538 AWGFiltABoxCar = IntVar(0)
539 AWGFiltBBoxCar = IntVar(0)
540 AWGFiltACoef = [1]
541 AWGFiltBCoef = [1]
542 VFilterA = {}
543 VFilterB = {}
544 SampleRateStatus = IntVar(0)
545 ETSStatus = IntVar(0)
546 ETSDisp = IntVar(0)
547 ETSDir = IntVar(0)
548 #
549 AWGAwaveform = []
550 AWGA2X = [] # array for odd numbers samples when in 2x sample rate
551 AWGBwaveform = []
552 AWGB2X = [] # array for odd numbers samples when in 2x sample rate
553 VmemoryA = numpy.ones(1) # The memory for averaging
554 VmemoryB = numpy.ones(1)
555 ImemoryA = numpy.ones(1) # The memory for averaging
556 ImemoryB = numpy.ones(1)
557 TRACEresetTime = True # True for first new trace, false for averageing
558 TRACEresetFreq = True # True for first new trace, false for averageing
559 AWGScreenStatus = IntVar(0)
560 
561 T1Vline = [] # Voltage Trace line channel A
562 T2Vline = [] # Voltage Trace line channel B
563 T1Iline = [] # Current Trace line channel A
564 T2Iline = [] # Current Trace line channel B
565 TMAVline = [] # Voltage Trace line MUX channel A
566 TMBVline = [] # Voltage Trace line MUX channel B
567 TMCVline = [] # Voltage Trace line MUX channel C
568 TMDVline = [] # Voltage Trace line MUX channel D
569 TMARline = [] # V reference Trace line MUX channel A
570 TMBRline = [] # V reference Trace line MUX channel B
571 TMCRline = [] # V reference line MUX channel C
572 TMDRline = [] # V reference line MUX channel D
573 XYlineVA = [] # XY Trace lines
574 XYlineVB = []
575 XYlineIA = []
576 XYlineIB = []
577 XYlineM = []
578 XYlineMX = []
579 XYlineMY = []
580 XYRlineVA = [] # XY reference trace lines
581 XYRlineVB = []
582 XYRlineIA = []
583 XYRlineIB = []
584 XYRlineM = []
585 XYRlineMX = []
586 XYRlineMY = []
587 Tmathline = [] # Time Math trace line
588 TMXline = [] # Time X math Trace line
589 TMYline = [] # Time Y math Trace line
590 T1VRline = [] # V reference Trace line channel A
591 T2VRline = [] # V reference Trace line channel B
592 T1IRline = [] # I reference Trace line channel A
593 T2IRline = [] # I reference Trace line channel B
594 TMRline = [] # Math reference Trace line
595 D0line = [] # Digital input 0 Trace line
596 D1line = [] # Digital input 1 Trace line
597 D2line = [] # Digital input 2 Trace line
598 D3line = [] # Digital input 3 Trace line
599 Triggerline = [] # Triggerline
600 Triggersymbol = [] # Trigger symbol
601 #
602 SHOWsamples = 4000 # Number of samples on the screen
603 SCstart = 0 # Start sample of the trace
604 HozPoss = 0.0
605 Is_Triggered = 0
606 #
607 TRACES = 1 # Number of traces 1 or 2
608 TRACESread = 0 # Number of traces that have been read from ALM
609 ScreenTrefresh = IntVar(0)
610 ScreenXYrefresh = IntVar(0)
611 #
612 NSteps = IntVar(0) # number of frequency sweep steps
613 NSteps.set(128)
614 LoopNum = IntVar(0)
615 LoopNum.set(1)
616 LastWindow = -1
617 LastSMPfft = 0
618 CurrentFreqX = X0LBP + 14
619 FBins = numpy.linspace(0, 50000, num=16384)
620 FStep = numpy.linspace(0, 16384, num=NSteps.get())
621 FSweepMode = IntVar(0)
622 FSweepCont = IntVar(0)
623 FStepSync = IntVar(0)
624 FSweepSync = IntVar(0)
625 ShowCA_VdB = IntVar(0) # curves to display variables
626 ShowCA_P = IntVar(0)
627 ShowCB_VdB = IntVar(0)
628 ShowCB_P = IntVar(0)
629 ShowMarkerBP = IntVar(0)
630 ShowCA_RdB = IntVar(0)
631 ShowCA_RP = IntVar(0)
632 ShowCB_RdB = IntVar(0)
633 ShowCB_RP = IntVar(0)
634 ShowMathBP = IntVar(0)
635 ShowRMathBP = IntVar(0)
636 SingleShotSA = IntVar(0) # variable for Single Shot sweeps
637 FSweepAdB = []
638 FSweepBdB = []
639 FSweepAPh = []
640 FSweepBPh = []
641 NSweepSeriesR = []
642 NSweepSeriesX = []
643 NSweepSeriesMag = [] # in ohms
644 NSweepSeriesAng = [] # in degrees
645 NSweepParallelR = []
646 NSweepParallelC = []
647 NSweepParallelL = []
648 NSweepSeriesC = []
649 NSweepSeriesL = []
650 NetworkScreenStatus = IntVar(0)
651 BDSweepFile = IntVar(0)
652 FileSweepFreq = []
653 FileSweepAmpl = []
654 #
655 MarkerNum = MarkerFreqNum = 0
656 ShowTCur = IntVar(0)
657 ShowVCur = IntVar(0)
658 TCursor = VCursor = 0
659 ShowXCur = IntVar(0)
660 ShowYCur = IntVar(0)
661 XCursor = YCursor = 0
662 ShowFCur = IntVar(0)
663 ShowdBCur = IntVar(0)
664 FCursor = dBCursor = 0
665 ShowBPCur = IntVar(0)
666 ShowBdBCur = IntVar(0)
667 BPCursor = BdBCursor = 0
668 RUNstatus = IntVar(0) # 0 stopped, 1 start, 2 running, 3 stop and restart, 4 stop
669 PowerStatus = 1
670 TRIGGERsample = 0 # AD sample trigger point
671 DX = 0 # interpolated trigger point
672 
673 DBdivlist = [1, 2, 3, 5, 10, 15, 20] # dB per division
674 DBdivindex = IntVar(0) # 10 dB/div as initial value
675 DBdivindex.set(4)
676 DBlevel = IntVar(0) # Reference level
677 DBlevel.set(0)
678 DBdivindexBP = IntVar(0) # 10 dB/div as initial value
679 DBdivindexBP.set(4)
680 DBlevelBP = IntVar(0) # Reference level
681 DBlevelBP.set(0)
682 hldn = 0
683 SpectrumScreenStatus = IntVar(0)
684 SmoothCurvesSA = IntVar(0)
685 SmoothCurvesBP = IntVar(0)
686 CutDC = IntVar(0)
687 IAScreenStatus = IntVar(0)
688 NqPScreenStatus = IntVar(0)
689 NqPDisp = IntVar(0)
690 NiCScreenStatus = IntVar(0)
691 NiCDisp = IntVar(0)
692 ImpedanceMagnitude = 0.0 # in ohms
693 ImpedanceAngle = 0.0 # in degrees
694 ImpedanceRseries = 0.0 # in ohms
695 ImpedanceXseries = 0.0 # in ohms
696 Show_Rseries = IntVar(0)
697 Show_Xseries = IntVar(0)
698 Show_Magnitude = IntVar(0)
699 Show_Angle = IntVar(0)
700 Show_RseriesRef = IntVar(0)
701 Show_XseriesRef = IntVar(0)
702 Show_MagnitudeRef = IntVar(0)
703 Show_AngleRef = IntVar(0)
704 
705 TIARline = []
706 TIAXline = []
707 TIAMagline = []
708 TIAAngline = []
709 TIAMline = []
710 TIAMRline = []
711 RefIARline = []
712 RefIAXline = []
713 RefIAMagline = []
714 RefIAAngline = []
715 IASource = IntVar(0)
716 IAGridType = IntVar(0)
717 
718 DisplaySeries = IntVar(0)
719 IA_Ext_Conf = IntVar(0)
720 IASweepSaved = IntVar(0)
721 OverRangeFlagA = 0
722 OverRangeFlagB = 0
723 PeakdbA = 10
724 PeakdbB = 10
725 PeakRelPhase = 0.0
726 PeakfreqA = 100
727 PeakfreqB = 1000
728 OhmStatus = IntVar(0)
729 OhmRunStatus = IntVar(0)
730 FFTbandwidth = 0 # The FFT bandwidth
731 FFTBuffA = [] # Clear the FFTBuff array for trace A
732 FFTBuffB = [] # Clear the FFTBuff array for trace B
733 FFTresultA = [] # FFT result CHA
734 PhaseA = []
735 FFTresultB = [] # FFT result CHB
736 PhaseB = []
737 FFTresultAB = []
738 FFTwindowname = "--" # The FFT window name
739 FFTmemoryA = numpy.ones(1) # The memory for averaging
740 PhaseMemoryA = numpy.ones(1)
741 FFTmemoryB = numpy.ones(1) # The memory for averaging
742 PhaseMemoryB = numpy.ones(1)
743 SMPfftpwrTwo = IntVar(0) # The power of two of SMPfft
744 SMPfftpwrTwo.set(11)
745 SMPfft = 2 ** SMPfftpwrTwo.get() # Initialize
746 Two28 = 268435456
747 FFTwindowshape = numpy.ones(SMPfft) # The FFT window curve
748 
749 T1Fline = [] # Frequency Trace line channel A
750 T2Fline = [] # Frequency Trace line channel B
751 T1Pline = [] # Phase angle Trace line channel A - B
752 T2Pline = [] # Phase angle Trace line channel B - A
753 T1FRline = [] # F reference Trace line channel A
754 T2FRline = [] # F reference Trace line channel B
755 T1PRline = [] # Phase reference Trace line channel A - B
756 T2PRline = [] # Phase reference Trace line channel B - A
757 TFMline = [] # Frequency Math Trace
758 TFRMline = [] # Frequency reference Math Trace
759 FreqTraceMode = IntVar(0) # 1 normal mode, 2 max hold mode, 3 average mode
760 FreqTraceMode.set(1)
761 
762 TAFline = [] # Bode Freq Trace line channel A
763 TBFline = [] # Bode Freq Trace line channel B
764 TAPline = [] # Bode Phase angle Trace line channel A - B
765 TBPline = [] # Bode Phase angle Trace line channel B - A
766 TAFRline = [] # Bode F reference Trace line channel A
767 TBFRline = [] # Bode F reference Trace line channel B
768 TAPRline = [] # Bode Phase reference Trace line channel A - B
769 TBPRline = [] # Bode Phase reference Trace line channel B - A
770 TBPMline = [] # Bode Frequency Math Trace
771 TBPRMline = [] # Bode Frequency reference Math Trace
772 #
773 MinSamplesSA = 64
774 MaxSamplesSA = 65536
775 #
776 MathScreenStatus = IntVar(0)
777 #
778 XYScreenStatus = IntVar(0)
779 Xsignal = IntVar(0) # Signal for X axis variable
780 Xsignal.set(1)
781 YsignalVA = IntVar(0) # Signal for Y axis variable
782 YsignalVB = IntVar(0)
783 YsignalIA = IntVar(0)
784 YsignalIB = IntVar(0)
785 YsignalM = IntVar(0)
786 YsignalMX = IntVar(0)
787 YsignalMY = IntVar(0)
788 YsignalVB.set(1)
789 XYRefAV = IntVar(0) # show reference XY traces
790 XYRefBV = IntVar(0)
791 XYRefAI = IntVar(0)
792 XYRefBI = IntVar(0)
793 XYRefM = IntVar(0)
794 XYRefMX = IntVar(0)
795 XYRefMY = IntVar(0)
796 # show Analog Input Mux Variables
797 Show_CBA = IntVar(0)
798 Show_CBB = IntVar(0)
799 Show_CBC = IntVar(0)
800 Show_CBD = IntVar(0)
801 ShowRMA = IntVar(0)
802 ShowRMB = IntVar(0)
803 ShowRMC = IntVar(0)
804 ShowRMD = IntVar(0)
805 D0 = IntVar(0)
806 D1 = IntVar(0)
807 D2 = IntVar(0)
808 D3 = IntVar(0)
809 D4 = IntVar(0)
810 D5 = IntVar(0)
811 D6 = IntVar(0)
812 D7 = IntVar(0)
813 D0.set(0x50)
814 D1.set(0x50)
815 D2.set(0x50)
816 D3.set(0x50)
817 D4.set(0x50)
818 D5.set(0x50)
819 D6.set(0x50)
820 D7.set(0x50)
821 PIO_0 = 28
822 PIO_1 = 29
823 PIO_2 = 47
824 PIO_3 = 3
825 PIO_4 = 4
826 PIO_5 = 5
827 PIO_6 = 6
828 PIO_7 = 7
829 #
830 SCLKPort = IntVar(0)
831 SDATAPort = IntVar(0)
832 SLATCHPort = IntVar(0)
833 
834 
835 hipulse = """
836 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
837 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
838 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
839 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
840 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
841 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
842 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
843 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
844 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
845 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
846 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
847 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
848 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
849 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
850 sKDBgw8AKFzIsKFChA4jMoQoUSJFAAgHLryYUeDGgx8zhiw4EuRDkxg7ltR4UmRLki9RclQZk2VK
851 lzdh5pTJE+dMnz1/6uyYsKZHowRXHt1pcGREohUbQo2qNKlDolgFBgQAOw==
852 """
853 hipulseimg = PhotoImage(data=hipulse)
854 
855 lowpulse = """
856 R0lGODlhGQAYAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
857 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
858 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
859 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
860 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
861 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
862 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
863 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
864 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
865 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
866 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
867 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
868 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
869 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///ywAAAAAGQAYAAAIZwAfCBxI
870 sKBBggASKgRwEOHChwsbDoRIkaHEBxQdWpSosGHHix8NhvSYkORGkyhBljw4kuVKkS9TwjzpkubE
871 mDVl6tR4ESPOmzYLtgTac6hAozxzqgzqkynRmhUhmoz6cCpVpD0vBgQAOw==
872 """
873 lowpulseimg = PhotoImage(data=lowpulse)
874 
875 class CreateToolTip(object):
876 
877  def __init__(self, widget, text='widget info'):
878  self.waittime = 500 #miliseconds
879  self.wraplength = 100 #pixels
880  self.widget = widget
881  self.text = text
882  self.widget.bind("<Enter>", self.enter)
883  self.widget.bind("<Leave>", self.leave)
884  self.widget.bind("<ButtonPress>", self.leave)
885  self.id = None
886  self.tw = None
887 
888  def enter(self, event=None):
889  self.schedule()
890 
891  def leave(self, event=None):
892  self.unschedule()
893  self.hidetip()
894 
895  def schedule(self):
896  self.unschedule()
897  self.id = self.widget.after(self.waittime, self.showtip)
898 
899  def unschedule(self):
900  id = self.id
901  self.id = None
902  if id:
903  self.widget.after_cancel(id)
904 
905  def showtip(self, event=None):
906  x = y = 0
907  x, y, cx, cy = self.widget.bbox("insert")
908  x += self.widget.winfo_rootx() + 25
909  y += self.widget.winfo_rooty() + 20
910  # creates a toplevel window
911  self.tw = Toplevel(self.widget)
912  # Leaves only the label and removes the app window
913  self.tw.wm_overrideredirect(True)
914  self.tw.wm_geometry("+%d+%d" % (x, y))
915  label = Label(self.tw, text=self.text, justify='left',
916  background="#ffffe0", foreground="#000000",
917  relief='solid', borderwidth=1,
918  wraplength = self.wraplength)
919  label.pack(ipadx=1)
920 
921  def hidetip(self):
922  tw = self.tw
923  self.tw= None
924  if tw:
925  tw.destroy()
926 
927  def configure(self, text):
928  self.text = text
929 #
930 # =========== Start widgets routines =============================
931 
933 def BSaveConfig(filename):
934  global TgInput, TgEdge, ManualTrigger, SingleShot, AutoLevel, SingleShotSA
935  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
936  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
937  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
938  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
939  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
940  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
941  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
942  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
943  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
944  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
945  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
946  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
947  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
948  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
949  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
950  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
951  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase
952  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
953  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
954  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
955  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, DacScreenStatus, DigScreenStatus
956  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
957  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
958  global TimeDisp, XYDisp, FreqDisp, IADisp, XYScreenStatus, IAScreenStatus, SpectrumScreenStatus
959  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry, AWGAPhaseDelay, AWGBPhaseDelay
960  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasDelay
961  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb, ChopMuxMode, ChopTrig, DualMuxMode
962  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow
963  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, HozPossentry
964  global SmoothCurvesBP, bodewindow, AWG_Amp_Mode, ColorMode
965  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp
966  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP
967  global BPSweepMode, BPSweepCont, BodeScreenStatus, RevDate, SweepStepBodeEntry
968  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
969  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
970  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
971  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
972  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
973  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
974  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
975  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
976  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
977  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
978  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter, NetworkScreenStatus
979  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
980  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
981  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
982  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAcsvFile, AWGBcsvFile
983  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGAwavFile, AWGBwavFile
984  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
985  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
986  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
987  global DigFiltStatus, DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
988  global phawindow, PhAca, PhAScreenStatus, PhADisp
989  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, BoardStatus, boardwindow, BrdSel
990  global VScale, IScale, RefphEntry, EnableScopeOnly, Roll_Mode
991  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
992  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
993  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
994  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
995  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
996 
997  # open Config file for Write?
998  try:
999  ConfgFile = open(filename, "w")
1000  except: # didn't work? then just return
1001  return
1002  # Save Window placements
1003  ConfgFile.write("root.geometry('+" + str(root.winfo_x()) + '+' + str(root.winfo_y()) + "')\n")
1004  if EnableScopeOnly == 0:
1005  ConfgFile.write("awgwindow.geometry('+" + str(awgwindow.winfo_x()) + '+' + str(awgwindow.winfo_y()) + "')\n")
1006  ConfgFile.write('GRW = ' + str(GRW) + '\n')
1007  ConfgFile.write('GRH = ' + str(GRH) + '\n')
1008  ConfgFile.write('ColorMode.set(' + str(ColorMode.get()) + ')\n')
1009  # Windows configuration
1010  ConfgFile.write('MathString = "' + MathString + '"\n')
1011  ConfgFile.write('MathUnits = "' + MathUnits + '"\n')
1012  ConfgFile.write('MathAxis = "' + MathAxis + '"\n')
1013  ConfgFile.write('MathXString = "' + MathXString + '"\n')
1014  ConfgFile.write('MathXUnits = "' + MathXUnits + '"\n')
1015  ConfgFile.write('MathXAxis = "' + MathXAxis + '"\n')
1016  ConfgFile.write('MathYString = "' + MathYString + '"\n')
1017  ConfgFile.write('MathYUnits = "' + MathYUnits + '"\n')
1018  ConfgFile.write('MathYAxis = "' + MathYAxis + '"\n')
1019  if BoardStatus.get() > 0:
1020  ConfgFile.write('MakeBoardScreen()\n')
1021  ConfgFile.write("boardwindow.geometry('+" + str(boardwindow.winfo_x()) + '+' + str(boardwindow.winfo_y()) + "')\n")
1022  ConfgFile.write('BrdSel.set(' + str(BrdSel.get()) + ')\n')
1023  ConfgFile.write('SelectBoard()\n')
1024  else:
1025  ConfgFile.write('DestroyBoardScreen()\n')
1026  if MathScreenStatus.get() > 0:
1027  ConfgFile.write('NewEnterMathControls()\n')
1028  ConfgFile.write("MathWindow.geometry('+" + str(MathWindow.winfo_x()) + '+' + str(MathWindow.winfo_y()) + "')\n")
1029  else:
1030  ConfgFile.write('DestroyMathScreen()\n')
1031  if XYScreenStatus.get() > 0:
1032  ConfgFile.write('GRWXY = ' + str(GRWXY) + '\n')
1033  ConfgFile.write('GRHXY = ' + str(GRHXY) + '\n')
1034  ConfgFile.write('MakeXYWindow()\n')
1035  ConfgFile.write("xywindow.geometry('+" + str(xywindow.winfo_x()) + '+' + str(xywindow.winfo_y()) + "')\n")
1036  ConfgFile.write('CHAsbxy.delete(0,END)\n')
1037  ConfgFile.write('CHAsbxy.insert(0, ' + CHAsbxy.get() + ')\n')
1038  ConfgFile.write('CHAIsbxy.delete(0,END)\n')
1039  ConfgFile.write('CHAIsbxy.insert(0, ' + CHAIsbxy.get() + ')\n')
1040  ConfgFile.write('CHAVPosEntryxy.delete(0,END)\n')
1041  ConfgFile.write('CHAVPosEntryxy.insert(4, ' + CHAVPosEntryxy.get() + ')\n')
1042  ConfgFile.write('CHAIPosEntryxy.delete(0,END)\n')
1043  ConfgFile.write('CHAIPosEntryxy.insert(4, ' + CHAIPosEntryxy.get() + ')\n')
1044  ConfgFile.write('CHBsbxy.delete(0,END)\n')
1045  ConfgFile.write('CHBsbxy.insert(0, ' + CHBsbxy.get() + ')\n')
1046  ConfgFile.write('CHBIsbxy.delete(0,END)\n')
1047  ConfgFile.write('CHBIsbxy.insert(0, ' + CHBIsbxy.get() + ')\n')
1048  ConfgFile.write('CHBVPosEntryxy.delete(0,END)\n')
1049  ConfgFile.write('CHBVPosEntryxy.insert(4, ' + CHBVPosEntryxy.get() + ')\n')
1050  ConfgFile.write('CHBIPosEntryxy.delete(0,END)\n')
1051  ConfgFile.write('CHBIPosEntryxy.insert(4, ' + CHBIPosEntryxy.get() + ')\n')
1052  else:
1053  ConfgFile.write('DestroyXYScreen()\n')
1054  if IAScreenStatus.get() > 0:
1055  ConfgFile.write('GRWIA = ' + str(GRWIA) + '\n')
1056  ConfgFile.write('GRHIA = ' + str(GRHIA) + '\n')
1057  ConfgFile.write('MakeIAWindow()\n')
1058  ConfgFile.write("iawindow.geometry('+" + str(iawindow.winfo_x()) + '+' + str(iawindow.winfo_y()) + "')\n")
1059  ConfgFile.write('IASource.set(' + str(IASource.get()) + ')\n')
1060  ConfgFile.write('DisplaySeries.set(' + str(DisplaySeries.get()) + ')\n')
1061  ConfgFile.write('RsystemEntry.delete(0,END)\n')
1062  ConfgFile.write('RsystemEntry.insert(5, ' + RsystemEntry.get() + ')\n')
1063  ConfgFile.write('ResScale.delete(0,END)\n')
1064  ConfgFile.write('ResScale.insert(5, ' + ResScale.get() + ')\n')
1065  ConfgFile.write('GainCorEntry.delete(0,END)\n')
1066  ConfgFile.write('GainCorEntry.insert(5, ' + GainCorEntry.get() + ')\n')
1067  ConfgFile.write('PhaseCorEntry.delete(0,END)\n')
1068  ConfgFile.write('PhaseCorEntry.insert(5, ' + PhaseCorEntry.get() + ')\n')
1069  ConfgFile.write('NetworkScreenStatus.set(' + str(NetworkScreenStatus.get()) + ')\n')
1070  else:
1071  ConfgFile.write('DestroyIAScreen()\n')
1072  if SpectrumScreenStatus.get() > 0:
1073  ConfgFile.write('GRWF = ' + str(GRWF) + '\n')
1074  ConfgFile.write('GRHF = ' + str(GRHF) + '\n')
1075  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1076  ConfgFile.write('MakeSpectrumWindow()\n')
1077  ConfgFile.write("freqwindow.geometry('+" + str(freqwindow.winfo_x()) + '+' + str(freqwindow.winfo_y()) + "')\n")
1078  ConfgFile.write('ShowC1_VdB.set(' + str(ShowC1_VdB.get()) + ')\n')
1079  ConfgFile.write('ShowC1_P.set(' + str(ShowC1_P.get()) + ')\n')
1080  ConfgFile.write('ShowC2_VdB.set(' + str(ShowC2_VdB.get()) + ')\n')
1081  ConfgFile.write('ShowC2_P.set(' + str(ShowC2_P.get()) + ')\n')
1082  ConfgFile.write('StartFreqEntry.delete(0,END)\n')
1083  ConfgFile.write('StartFreqEntry.insert(5, ' + StartFreqEntry.get() + ')\n')
1084  ConfgFile.write('StopFreqEntry.delete(0,END)\n')
1085  ConfgFile.write('StopFreqEntry.insert(5, ' + StopFreqEntry.get() + ')\n')
1086  ConfgFile.write('HScale.set(' + str(HScale.get()) + ')\n')
1087  ConfgFile.write('FreqTraceMode.set(' + str(FreqTraceMode.get()) + ')\n')
1088  ConfgFile.write('SingleShotSA.set(' + str(SingleShotSA.get()) + ')\n')
1089  else:
1090  ConfgFile.write('DestroySpectrumScreen()\n')
1091  #
1092  if DacScreenStatus.get() > 0:
1093  ConfgFile.write('MakeDacScreen()\n')
1094  ConfgFile.write("win1.geometry('+" + str(win1.winfo_x()) + '+' + str(win1.winfo_y()) + "')\n")
1095  else:
1096  ConfgFile.write('DestroyDacScreen()\n')
1097  if DigScreenStatus.get() > 0:
1098  ConfgFile.write('MakeDigScreen()\n')
1099  ConfgFile.write("win2.geometry('+" + str(win2.winfo_x()) + '+' + str(win2.winfo_y()) + "')\n")
1100  else:
1101  ConfgFile.write('DestroyDigScreen()\n')
1102  if EnableHSsampling > 0:
1103  ConfgFile.write('FminEntry.delete(0,"end")\n')
1104  ConfgFile.write('FminEntry.insert(0, ' + FminEntry.get() + ')\n')
1105  ConfgFile.write('HtMulEntry.delete(0,"end")\n')
1106  ConfgFile.write('HtMulEntry.insert(0, ' + HtMulEntry.get() + ')\n')
1107  ConfgFile.write('Auto_ETS_Comp.set(' + str(Auto_ETS_Comp.get()) + ')\n')
1108  try:
1109  ConfgFile.write('ets_TC1Entry.delete(0,"end")\n')
1110  ConfgFile.write('ets_TC1Entry.insert(0, ' + ets_TC1Entry.get() + ')\n')
1111  ConfgFile.write('ETS_TC1.set(' + ets_TC1Entry.get() + ')\n')
1112  ConfgFile.write('ets_A1Entry.delete(0,"end")\n')
1113  ConfgFile.write('ets_A1Entry.insert(0, ' + ets_A1Entry.get() + ')\n')
1114  ConfgFile.write('ETS_A1.set(' + ets_A1Entry.get() + ')\n')
1115  ConfgFile.write('ets_TC2Entry.delete(0,"end")\n')
1116  ConfgFile.write('ets_TC2Entry.insert(0, ' + ets_TC2Entry.get() + ')\n')
1117  ConfgFile.write('ETS_TC2.set(' + ets_TC2Entry.get() + ')\n')
1118  ConfgFile.write('ets_A2Entry.delete(0,"end")\n')
1119  ConfgFile.write('ets_A2Entry.insert(0, ' + ets_A2Entry.get() + ')\n')
1120  ConfgFile.write('ETS_A2.set(' + ets_A2Entry.get() + ')\n')
1121  except:
1122  ConfgFile.write('ETS_TC1.set(' + str(ETS_TC1.get()) + ')\n')
1123  ConfgFile.write('ETS_A1.set(' + str(ETS_A1.get()) + ')\n')
1124  ConfgFile.write('ETS_TC2.set(' + str(ETS_TC2.get()) + ')\n')
1125  ConfgFile.write('ETS_A2.set(' + str(ETS_A2.get()) + ')\n')
1126  if DigFiltStatus.get() == 1:
1127  ConfgFile.write('MakeDigFiltWindow()\n')
1128  ConfgFile.write("digfltwindow.geometry('+" + str(digfltwindow.winfo_x()) + '+' + str(digfltwindow.winfo_y()) + "')\n")
1129  ConfgFile.write('DigFiltABoxCar.set(' + str(DigFiltABoxCar.get()) + ')\n')
1130  ConfgFile.write('DigFiltBBoxCar.set(' + str(DigFiltBBoxCar.get()) + ')\n')
1131  ConfgFile.write('BCALenEntry.delete(0,"end")\n')
1132  ConfgFile.write('BCALenEntry.insert(0, ' + BCALenEntry.get() + ')\n')
1133  ConfgFile.write('BCBLenEntry.delete(0,"end")\n')
1134  ConfgFile.write('BCBLenEntry.insert(0, ' + BCBLenEntry.get() + ')\n')
1135  ConfgFile.write('AWGALenEntry.delete(0,"end")\n')
1136  ConfgFile.write('AWGALenEntry.insert(0, ' + AWGALenEntry.get() + ')\n')
1137  ConfgFile.write('AWGFiltABoxCar.set(' + str(AWGFiltABoxCar.get()) + ')\n')
1138  ConfgFile.write('AWGBLenEntry.delete(0,"end")\n')
1139  ConfgFile.write('AWGBLenEntry.insert(0, ' + AWGBLenEntry.get() + ')\n')
1140  ConfgFile.write('AWGFiltBBoxCar.set(' + str(AWGFiltBBoxCar.get()) + ')\n')
1141  ConfgFile.write('BuildBoxCarA()\n')
1142  ConfgFile.write('BuildBoxCarB()\n')
1143  ConfgFile.write('BuildAWGBoxCarA()\n')
1144  ConfgFile.write('BuildAWGBoxCarB()\n')
1145  else:
1146  ConfgFile.write('DestroyDigFiltScreen()\n')
1147  if MinigenScreenStatus.get() == 1:
1148  ConfgFile.write('MakeMinigenWindow()\n')
1149  ConfgFile.write("minigenwindow.geometry('+" + str(minigenwindow.winfo_x()) + '+' + str(minigenwindow.winfo_y()) + "')\n")
1150  ConfgFile.write('MinigenMode.set(' + str(MinigenMode.get()) + ')\n')
1151  ConfgFile.write('MinigenFout.delete(0,END)\n')
1152  ConfgFile.write('MinigenFout.insert(4, ' + MinigenFout.get() + ')\n')
1153  ConfgFile.write('MinigenFclk.delete(0,END)\n')
1154  ConfgFile.write('MinigenFclk.insert(4, ' + MinigenFclk.get() + ')\n')
1155  ConfgFile.write('SCLKPort.set(' + str(SCLKPort.get()) + ')\n')
1156  ConfgFile.write('SDATAPort.set(' + str(SDATAPort.get()) + ')\n')
1157  ConfgFile.write('SLATCHPort.set(' + str(SLATCHPort.get()) + ')\n')
1158  else:
1159  ConfgFile.write('DestroyMinigenScreen()\n')
1160  if MuxScreenStatus.get() == 1:
1161  ConfgFile.write('MakeMuxModeWindow()\n')
1162  ConfgFile.write("muxwindow.geometry('+" + str(muxwindow.winfo_x()) + '+' + str(muxwindow.winfo_y()) + "')\n")
1163  ConfgFile.write('Show_CBA.set(' + str(Show_CBA.get()) + ')\n')
1164  ConfgFile.write('Show_CBB.set(' + str(Show_CBB.get()) + ')\n')
1165  ConfgFile.write('Show_CBC.set(' + str(Show_CBC.get()) + ')\n')
1166  ConfgFile.write('Show_CBD.set(' + str(Show_CBD.get()) + ')\n')
1167  ConfgFile.write('MuxEnb.set(' + str(MuxEnb.get()) + ')\n')
1168  ConfgFile.write('DualMuxMode.set(' + str(DualMuxMode.get()) + ')\n')
1169  ConfgFile.write('ChopMuxMode.set(' + str(ChopMuxMode.get()) + ')\n')
1170  ConfgFile.write('ChopTrig.set(' + str(ChopTrig.get()) + ')\n')
1171  ConfgFile.write('CHB_Asb.delete(0,END)\n')
1172  ConfgFile.write('CHB_Asb.insert(0, ' + CHB_Asb.get() + ')\n')
1173  ConfgFile.write('CHB_Bsb.delete(0,END)\n')
1174  ConfgFile.write('CHB_Bsb.insert(0, ' + CHB_Bsb.get() + ')\n')
1175  ConfgFile.write('CHB_Csb.delete(0,END)\n')
1176  ConfgFile.write('CHB_Csb.insert(0, ' + CHB_Csb.get() + ')\n')
1177  ConfgFile.write('CHB_Dsb.delete(0,END)\n')
1178  ConfgFile.write('CHB_Dsb.insert(0, ' + CHB_Dsb.get() + ')\n')
1179  ConfgFile.write('CHB_APosEntry.delete(0,END)\n')
1180  ConfgFile.write('CHB_APosEntry.insert(4, ' + CHB_APosEntry.get() + ')\n')
1181  ConfgFile.write('CHB_BPosEntry.delete(0,END)\n')
1182  ConfgFile.write('CHB_BPosEntry.insert(4, ' + CHB_BPosEntry.get() + ')\n')
1183  ConfgFile.write('CHB_CPosEntry.delete(0,END)\n')
1184  ConfgFile.write('CHB_CPosEntry.insert(4, ' + CHB_CPosEntry.get() + ')\n')
1185  ConfgFile.write('CHB_DPosEntry.delete(0,END)\n')
1186  ConfgFile.write('CHB_DPosEntry.insert(4, ' + CHB_DPosEntry.get() + ')\n')
1187  else:
1188  ConfgFile.write('DestroyMuxScreen()\n')
1189  # Save Phase Anayzer stuff after Analog Mux in case they are both open
1190  if PhAScreenStatus.get() > 0:
1191  ConfgFile.write('GRWPhA = ' + str(GRWPhA) + '\n')
1192  ConfgFile.write('GRHPhA = ' + str(GRHPhA) + '\n')
1193  ConfgFile.write('MakePhAWindow()\n')
1194  ConfgFile.write("phawindow.geometry('+" + str(phawindow.winfo_x()) + '+' + str(phawindow.winfo_y()) + "')\n")
1195  ConfgFile.write('VScale.delete(0,END)\n')
1196  ConfgFile.write('VScale.insert(0, ' + str(VScale.get()) + ')\n')
1197  ConfgFile.write('IScale.delete(0,END)\n')
1198  ConfgFile.write('IScale.insert(0, ' + str(IScale.get()) + ')\n')
1199  ConfgFile.write('RefphEntry.delete(0,END)\n')
1200  ConfgFile.write('RefphEntry.insert(0, "' + str(RefphEntry.get()) + '")\n')
1201  if vat_btn.config('text')[-1] == 'OFF':
1202  ConfgFile.write('vat_btn.config(text="OFF", style="Stop.TButton")\n')
1203  else:
1204  ConfgFile.write('vat_btn.config(text="ON", style="Run.TButton")\n')
1205  if MuxScreenStatus.get() == 0: # these buttons do not exist if Mux screen open
1206  if vbt_btn.config('text')[-1] == 'OFF':
1207  ConfgFile.write('vbt_btn.config(text="OFF", style="Stop.TButton")\n')
1208  else:
1209  ConfgFile.write('vbt_btn.config(text="ON", style="Run.TButton")\n')
1210  if vabt_btn.config('text')[-1] == 'OFF':
1211  ConfgFile.write('vabt_btn.config(text="OFF", style="Stop.TButton")\n')
1212  else:
1213  ConfgFile.write('vabt_btn.config(text="ON", style="Run.TButton")\n')
1214  else: # But these do
1215  ConfgFile.write('ShowPB_A.set(' + str(ShowPB_A.get()) + ')\n')
1216  ConfgFile.write('ShowPB_B.set(' + str(ShowPB_B.get()) + ')\n')
1217  ConfgFile.write('ShowPB_C.set(' + str(ShowPB_C.get()) + ')\n')
1218  ConfgFile.write('ShowPB_D.set(' + str(ShowPB_D.get()) + ')\n')
1219  if iat_btn.config('text')[-1] == 'OFF':
1220  ConfgFile.write('iat_btn.config(text="OFF", style="Stop.TButton")\n')
1221  else:
1222  ConfgFile.write('iat_btn.config(text="ON", style="Run.TButton")\n')
1223  if ibt_btn.config('text')[-1] == 'OFF':
1224  ConfgFile.write('ibt_btn.config(text="OFF", style="Stop.TButton")\n')
1225  else:
1226  ConfgFile.write('ibt_btn.config(text="ON", style="Run.TButton")\n')
1227  #
1228  else:
1229  ConfgFile.write('DestroyPhAScreen()\n')
1230  if BodeScreenStatus.get() == 1:
1231  ConfgFile.write('GRWBP = ' + str(GRWBP) + '\n')
1232  ConfgFile.write('GRHBP = ' + str(GRHBP) + '\n')
1233  ConfgFile.write('RelPhaseCenter.set(' + str(RelPhaseCenter.get()) + ')\n')
1234  ConfgFile.write('ImpedanceCenter.set(' + str(ImpedanceCenter.get()) + ')\n')
1235  ConfgFile.write('MakeBodeWindow()\n')
1236  ConfgFile.write("bodewindow.geometry('+" + str(bodewindow.winfo_x()) + '+' + str(bodewindow.winfo_y()) + "')\n")
1237  ConfgFile.write('ShowCA_VdB.set(' + str(ShowCA_VdB.get()) + ')\n')
1238  ConfgFile.write('ShowCB_VdB.set(' + str(ShowCB_VdB.get()) + ')\n')
1239  ConfgFile.write('ShowCA_P.set(' + str(ShowCA_P.get()) + ')\n')
1240  ConfgFile.write('ShowCB_P.set(' + str(ShowCB_P.get()) + ')\n')
1241  ConfgFile.write('ShowCA_RdB.set(' + str(ShowCA_RdB.get()) + ')\n')
1242  ConfgFile.write('ShowCA_RP.set(' + str(ShowCA_RP.get()) + ')\n')
1243  ConfgFile.write('ShowCB_RdB.set(' + str(ShowCB_RdB.get()) + ')\n')
1244  ConfgFile.write('ShowCB_RP.set(' + str(ShowCB_RP.get()) + ')\n')
1245  ConfgFile.write('BodeDisp.set(' + str(BodeDisp.get()) + ')\n')
1246  ConfgFile.write('ShowMarkerBP.set(' + str(ShowMarkerBP.get()) + ')\n')
1247  ConfgFile.write('ShowMathBP.set(' + str(ShowMathBP.get()) + ')\n')
1248  ConfgFile.write('ShowRMathBP.set(' + str(ShowRMathBP.get()) + ')\n')
1249  ConfgFile.write('HScaleBP.set(' + str(HScaleBP.get()) + ')\n')
1250  ConfgFile.write('NSteps.set(' + str(NSteps.get()) + ')\n')
1251  ConfgFile.write('DBdivindexBP.set(' + str(DBdivindexBP.get()) + ')\n')
1252  ConfgFile.write('DBlevelBP.set(' + str(DBlevelBP.get()) + ')\n')
1253  ConfgFile.write('FSweepMode.set(' + str(FSweepMode.get()) + ')\n')
1254  ConfgFile.write('SweepStepBodeEntry.delete(0,END)\n')
1255  ConfgFile.write('SweepStepBodeEntry.insert(4, ' + SweepStepBodeEntry.get() + ')\n')
1256  ConfgFile.write('StopBodeEntry.delete(0,END)\n')
1257  ConfgFile.write('StopBodeEntry.insert(4, ' + StopBodeEntry.get() + ')\n')
1258  ConfgFile.write('StartBodeEntry.delete(0,END)\n')
1259  ConfgFile.write('StartBodeEntry.insert(4, ' + StartBodeEntry.get() + ')\n')
1260  ConfgFile.write('Show_Rseries.set(' + str(Show_Rseries.get()) + ')\n')
1261  ConfgFile.write('Show_Xseries.set(' + str(Show_Xseries.get()) + ')\n')
1262  ConfgFile.write('Show_Magnitude.set(' + str(Show_Magnitude.get()) + ')\n')
1263  ConfgFile.write('Show_Angle.set(' + str(Show_Angle.get()) + ')\n')
1264  else:
1265  ConfgFile.write('DestroyBodeScreen()\n')
1266  if MeasureStatus.get() == 1:
1267  # Save strings
1268  ConfgFile.write('ChaLableSrring1 = "' + ChaLableSrring1 + '"\n')
1269  ConfgFile.write('ChaLableSrring2 = "' + ChaLableSrring2 + '"\n')
1270  ConfgFile.write('ChaLableSrring3 = "' + ChaLableSrring3 + '"\n')
1271  ConfgFile.write('ChaLableSrring4 = "' + ChaLableSrring4 + '"\n')
1272  ConfgFile.write('ChaLableSrring5 = "' + ChaLableSrring5 + '"\n')
1273  ConfgFile.write('ChaLableSrring6 = "' + ChaLableSrring6 + '"\n')
1274  ConfgFile.write('ChbLableSrring1 = "' + ChbLableSrring1 + '"\n')
1275  ConfgFile.write('ChbLableSrring2 = "' + ChbLableSrring2 + '"\n')
1276  ConfgFile.write('ChbLableSrring3 = "' + ChbLableSrring3 + '"\n')
1277  ConfgFile.write('ChbLableSrring4 = "' + ChbLableSrring4 + '"\n')
1278  ConfgFile.write('ChbLableSrring5 = "' + ChbLableSrring5 + '"\n')
1279  ConfgFile.write('ChbLableSrring6 = "' + ChbLableSrring6 + '"\n')
1280  ConfgFile.write('ChaMeasString1 = "' + ChaMeasString1 + '"\n')
1281  ConfgFile.write('ChaMeasString2 = "' + ChaMeasString2 + '"\n')
1282  ConfgFile.write('ChaMeasString3 = "' + ChaMeasString3 + '"\n')
1283  ConfgFile.write('ChaMeasString4 = "' + ChaMeasString4 + '"\n')
1284  ConfgFile.write('ChaMeasString5 = "' + ChaMeasString5 + '"\n')
1285  ConfgFile.write('ChaMeasString6 = "' + ChaMeasString6 + '"\n')
1286  ConfgFile.write('ChbMeasString1 = "' + ChbMeasString1 + '"\n')
1287  ConfgFile.write('ChbMeasString2 = "' + ChbMeasString2 + '"\n')
1288  ConfgFile.write('ChbMeasString3 = "' + ChbMeasString3 + '"\n')
1289  ConfgFile.write('ChbMeasString4 = "' + ChbMeasString4 + '"\n')
1290  ConfgFile.write('ChbMeasString5 = "' + ChbMeasString5 + '"\n')
1291  ConfgFile.write('ChbMeasString6 = "' + ChbMeasString6 + '"\n')
1292  ConfgFile.write('MakeMeasureScreen()\n')
1293  ConfgFile.write("measurewindow.geometry('+" + str(measurewindow.winfo_x()) + '+' + str(measurewindow.winfo_y()) + "')\n")
1294  else:
1295  ConfgFile.write('DestroyMeasuewScreen()\n')
1296  if ETSStatus.get() == 1: #
1297  ConfgFile.write('MakeETSWindow()\n')
1298  ConfgFile.write("etswindow.geometry('+" + str(etswindow.winfo_x()) + '+' + str(etswindow.winfo_y()) + "')\n")
1299  ConfgFile.write('ETSDisp.set(' + str(ETSDisp.get()) + ')\n')
1300  ConfgFile.write('ETSDir.set(' + str(ETSDir.get()) + ')\n')
1301  ConfgFile.write('FMulXEntry.delete(0,END)\n')
1302  ConfgFile.write('FMulXEntry.insert(6, ' + FMulXEntry.get() + ')\n')
1303  ConfgFile.write('DivXEntry.delete(0,END)\n')
1304  ConfgFile.write('DivXEntry.insert(4, ' + DivXEntry.get() + ')\n')
1305  ConfgFile.write('ETSts.delete(0,END)\n')
1306  ConfgFile.write('ETSts.insert(4, ' + ETSts.get() + ')\n')
1307  else:
1308  ConfgFile.write('DestroyETSScreen()\n')
1309  #
1310  ConfgFile.write('TRIGGERentry.delete(0,END)\n')
1311  ConfgFile.write('TRIGGERentry.insert(4, ' + TRIGGERentry.get() + ')\n')
1312  ConfgFile.write('HoldOffentry.delete(0,"end")\n')
1313  ConfgFile.write('HoldOffentry.insert(0, ' + HoldOffentry.get() + ')\n')
1314  ConfgFile.write('HozPossentry.delete(0,"end")\n')
1315  ConfgFile.write('HozPossentry.insert(0, ' + HozPossentry.get() + ')\n')
1316  ConfgFile.write('TMsb.delete(0,END)\n')
1317  ConfgFile.write('TMsb.insert(0, ' + TMsb.get() + ')\n')
1318  ConfgFile.write('TgInput.set(' + str(TgInput.get()) + ')\n')
1319  ConfgFile.write('AutoLevel.set(' + str(AutoLevel.get()) + ')\n')
1320  ConfgFile.write('ManualTrigger.set(' + str(ManualTrigger.get()) + ')\n')
1321  ConfgFile.write('SingleShot.set(' + str(SingleShot.get()) + ')\n')
1322  ConfgFile.write('TgEdge.set(' + str(TgEdge.get()) + ')\n')
1323  ConfgFile.write('Roll_Mode.set(' + str(Roll_Mode.get()) + ')\n')
1324  ConfgFile.write('Xsignal.set(' + str(Xsignal.get()) + ')\n')
1325  ConfgFile.write('YsignalVA.set(' + str(YsignalVA.get()) + ')\n')
1326  ConfgFile.write('YsignalIA.set(' + str(YsignalIA.get()) + ')\n')
1327  ConfgFile.write('YsignalVB.set(' + str(YsignalVB.get()) + ')\n')
1328  ConfgFile.write('YsignalIB.set(' + str(YsignalIB.get()) + ')\n')
1329  ConfgFile.write('YsignalM.set(' + str(YsignalM.get()) + ')\n')
1330  ConfgFile.write('YsignalMX.set(' + str(YsignalMX.get()) + ')\n')
1331  ConfgFile.write('YsignalMY.set(' + str(YsignalMY.get()) + ')\n')
1332  #
1333  ConfgFile.write('TimeDisp.set(' + str(TimeDisp.get()) + ')\n')
1334  ConfgFile.write('XYDisp.set(' + str(XYDisp.get()) + ')\n')
1335  ConfgFile.write('FreqDisp.set(' + str(FreqDisp.get()) + ')\n')
1336  ConfgFile.write('IADisp.set(' + str(IADisp.get()) + ')\n')
1337  ConfgFile.write('ShowC1_V.set(' + str(ShowC1_V.get()) + ')\n')
1338  ConfgFile.write('ShowC1_I.set(' + str(ShowC1_I.get()) + ')\n')
1339  ConfgFile.write('ShowC2_V.set(' + str(ShowC2_V.get()) + ')\n')
1340  ConfgFile.write('ShowC2_I.set(' + str(ShowC2_I.get()) + ')\n')
1341  ConfgFile.write('Show_MathX.set(' + str(Show_MathX.get()) + ')\n')
1342  ConfgFile.write('Show_MathY.set(' + str(Show_MathY.get()) + ')\n')
1343  ConfgFile.write('AutoCenterA.set(' + str(AutoCenterA.get()) + ')\n')
1344  ConfgFile.write('AutoCenterB.set(' + str(AutoCenterB.get()) + ')\n')
1345  ConfgFile.write('TRACEmodeTime.set(' + str(TRACEmodeTime.get()) + ')\n')
1346  #
1347  ConfgFile.write('CHAVPosEntry.delete(0,END)\n')
1348  ConfgFile.write('CHAVPosEntry.insert(4, ' + CHAVPosEntry.get() + ')\n')
1349  ConfgFile.write('CHAIPosEntry.delete(0,END)\n')
1350  ConfgFile.write('CHAIPosEntry.insert(4, ' + CHAIPosEntry.get() + ')\n')
1351  ConfgFile.write('CHAsb.delete(0,END)\n')
1352  ConfgFile.write('CHAsb.insert(0, ' + CHAsb.get() + ')\n')
1353  ConfgFile.write('CHAIsb.delete(0,END)\n')
1354  ConfgFile.write('CHAIsb.insert(0, ' + CHAIsb.get() + ')\n')
1355  #
1356  ConfgFile.write('CHBVPosEntry.delete(0,END)\n')
1357  ConfgFile.write('CHBVPosEntry.insert(4, ' + CHBVPosEntry.get() + ')\n')
1358  ConfgFile.write('CHBIPosEntry.delete(0,END)\n')
1359  ConfgFile.write('CHBIPosEntry.insert(4, ' + CHBIPosEntry.get() + ')\n')
1360  ConfgFile.write('CHBsb.delete(0,END)\n')
1361  ConfgFile.write('CHBsb.insert(0, ' + CHBsb.get() + ')\n')
1362  ConfgFile.write('CHBIsb.delete(0,END)\n')
1363  ConfgFile.write('CHBIsb.insert(0, ' + CHBIsb.get() + ')\n')
1364  # AWG stuff
1365  ConfgFile.write('AWG_Amp_Mode.set('+ str(AWG_Amp_Mode.get()) + ')\n')
1366  ConfgFile.write('AWGAMode.set('+ str(AWGAMode.get()) + ')\n')
1367  ConfgFile.write('AWGAIOMode.set('+ str(AWGAIOMode.get()) + ')\n')
1368  ConfgFile.write('AWGATerm.set('+ str(AWGATerm.get()) + ')\n')
1369  ConfgFile.write('AWGAPhaseDelay.set('+ str(AWGAPhaseDelay.get()) + ')\n')
1370  ConfgFile.write('AWGAAmplEntry.delete(0,END)\n')
1371  ConfgFile.write('AWGAAmplEntry.insert(4, ' + AWGAAmplEntry.get() + ')\n')
1372  ConfgFile.write('AWGAOffsetEntry.delete(0,END)\n')
1373  ConfgFile.write('AWGAOffsetEntry.insert(4, ' + AWGAOffsetEntry.get() + ')\n')
1374  ConfgFile.write('AWGAFreqEntry.delete(0,END)\n')
1375  ConfgFile.write('AWGAFreqEntry.insert(4, ' + AWGAFreqEntry.get() + ')\n')
1376  ConfgFile.write('AWGAPhaseEntry.delete(0,END)\n')
1377  ConfgFile.write('AWGAPhaseEntry.insert(4, ' + AWGAPhaseEntry.get() + ')\n')
1378  ConfgFile.write('AWGADutyCycleEntry.delete(0,END)\n')
1379  ConfgFile.write('AWGADutyCycleEntry.insert(4, ' + AWGADutyCycleEntry.get() + ')\n')
1380  ConfgFile.write('AWGAShape.set(' + str(AWGAShape.get()) + ')\n')
1381  ConfgFile.write('AWGARepeatFlag.set(' + str(AWGARepeatFlag.get()) + ')\n')
1382  ConfgFile.write('AWGABurstFlag.set(' + str(AWGABurstFlag.get()) + ')\n')
1383  ConfgFile.write('global AWGACycles; AWGACycles = ' + str(AWGACycles) + '\n')
1384  ConfgFile.write('global AWGABurstDelay; AWGABurstDelay = ' + str(AWGABurstDelay) + '\n')
1385  #
1386  ConfgFile.write('AWGBMode.set('+ str(AWGBMode.get()) + ')\n')
1387  ConfgFile.write('AWGBIOMode.set('+ str(AWGBIOMode.get()) + ')\n')
1388  ConfgFile.write('AWGBTerm.set('+ str(AWGBTerm.get()) + ')\n')
1389  ConfgFile.write('AWGBPhaseDelay.set('+ str(AWGBPhaseDelay.get()) + ')\n')
1390  ConfgFile.write('AWGBAmplEntry.delete(0,END)\n')
1391  ConfgFile.write('AWGBAmplEntry.insert(4, ' + AWGBAmplEntry.get() + ')\n')
1392  ConfgFile.write('AWGBOffsetEntry.delete(0,END)\n')
1393  ConfgFile.write('AWGBOffsetEntry.insert(4, ' + AWGBOffsetEntry.get() + ')\n')
1394  ConfgFile.write('AWGBFreqEntry.delete(0,END)\n')
1395  ConfgFile.write('AWGBFreqEntry.insert(4, ' + AWGBFreqEntry.get() + ')\n')
1396  ConfgFile.write('AWGBPhaseEntry.delete(0,END)\n')
1397  ConfgFile.write('AWGBPhaseEntry.insert(4, ' + AWGBPhaseEntry.get() + ')\n')
1398  ConfgFile.write('AWGBDutyCycleEntry.delete(0,END)\n')
1399  ConfgFile.write('AWGBDutyCycleEntry.insert(4, ' + AWGBDutyCycleEntry.get() + ')\n')
1400  ConfgFile.write('AWGBShape.set(' + str(AWGBShape.get()) + ')\n')
1401  ConfgFile.write('AWGBRepeatFlag.set(' + str(AWGBRepeatFlag.get()) + ')\n')
1402  ConfgFile.write('AWGBBurstFlag.set(' + str(AWGBBurstFlag.get()) + ')\n')
1403  ConfgFile.write('global AWGBCycles; AWGBCycles = ' + str(AWGBCycles) + '\n')
1404  ConfgFile.write('global AWGBBurstDelay; AWGBBurstDelay = ' + str(AWGBBurstDelay) + '\n')
1405  #
1406  ConfgFile.write('AWGSync.set(' + str(AWGSync.get()) + ')\n')
1407  ConfgFile.write('AWGAMathString = "' + AWGAMathString + '"\n')
1408  ConfgFile.write('AWGBMathString = "' + AWGBMathString + '"\n')
1409  ConfgFile.write('AWGAcsvFile = "' + AWGAcsvFile + '"\n')
1410  ConfgFile.write('AWGBcsvFile = "' + AWGBcsvFile + '"\n')
1411  ConfgFile.write('AWGAwavFile = "' + AWGAwavFile + '"\n')
1412  ConfgFile.write('AWGBwavFile = "' + AWGBwavFile + '"\n')
1413  #
1414  if EnableScopeOnly == 0:
1415  ConfgFile.write('AWGANoiseEntry.delete(0,END)\n')
1416  ConfgFile.write('AWGANoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1417  ConfgFile.write('AWGBNoiseEntry.delete(0,END)\n')
1418  ConfgFile.write('AWGBNoiseEntry.insert(4, ' + AWGBNoiseEntry.get() + ')\n')
1419  ConfgFile.write('AWGAsbnoise.delete(0,END)\n')
1420  ConfgFile.write('AWGAsbnoise.insert(4, "'+ str(AWGAsbnoise.get()) + '")\n')
1421  ConfgFile.write('AWGBsbnoise.delete(0,END)\n')
1422  ConfgFile.write('AWGBsbnoise.insert(4, "' + str(AWGBsbnoise.get()) + '")\n')
1423  #
1424  ConfgFile.write('CHAVGainEntry.delete(0,END)\n')
1425  ConfgFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
1426  ConfgFile.write('CHBVGainEntry.delete(0,END)\n')
1427  ConfgFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
1428  ConfgFile.write('CHAVOffsetEntry.delete(0,END)\n')
1429  ConfgFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
1430  ConfgFile.write('CHBVOffsetEntry.delete(0,END)\n')
1431  ConfgFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
1432  #
1433  ConfgFile.write('MeasDCV1.set(' + str(MeasDCV1.get()) + ')\n')
1434  ConfgFile.write('MeasMinV1.set(' + str(MeasMinV1.get()) + ')\n')
1435  ConfgFile.write('MeasMaxV1.set(' + str(MeasMaxV1.get()) + ')\n')
1436  ConfgFile.write('MeasBaseV1.set(' + str(MeasBaseV1.get()) + ')\n')
1437  ConfgFile.write('MeasTopV1.set(' + str(MeasTopV1.get()) + ')\n')
1438  ConfgFile.write('MeasMidV1.set(' + str(MeasMidV1.get()) + ')\n')
1439  ConfgFile.write('MeasPPV1.set(' + str(MeasPPV1.get()) + ')\n')
1440  ConfgFile.write('MeasRMSV1.set(' + str(MeasRMSV1.get()) + ')\n')
1441  ConfgFile.write('MeasDCI1.set(' + str(MeasDCI1.get()) + ')\n')
1442  ConfgFile.write('MeasMinI1.set(' + str(MeasMinI1.get()) + ')\n')
1443  ConfgFile.write('MeasMaxI1.set(' + str(MeasMaxI1.get()) + ')\n')
1444  ConfgFile.write('MeasMidI1.set(' + str(MeasMidI1.get()) + ')\n')
1445  ConfgFile.write('MeasPPI1.set(' + str(MeasPPI1.get()) + ')\n')
1446  ConfgFile.write('MeasRMSI1.set(' + str(MeasRMSI1.get()) + ')\n')
1447  ConfgFile.write('MeasDiffAB.set(' + str(MeasDiffAB.get()) + ')\n')
1448  ConfgFile.write('MeasDCV2.set(' + str(MeasDCV2.get()) + ')\n')
1449  ConfgFile.write('MeasMinV2.set(' + str(MeasMinV2.get()) + ')\n')
1450  ConfgFile.write('MeasMaxV2.set(' + str(MeasMaxV2.get()) + ')\n')
1451  ConfgFile.write('MeasBaseV2.set(' + str(MeasBaseV2.get()) + ')\n')
1452  ConfgFile.write('MeasTopV2.set(' + str(MeasTopV2.get()) + ')\n')
1453  ConfgFile.write('MeasMidV2.set(' + str(MeasMidV2.get()) + ')\n')
1454  ConfgFile.write('MeasPPV2.set(' + str(MeasPPV2.get()) + ')\n')
1455  ConfgFile.write('MeasRMSV2.set(' + str(MeasRMSV2.get()) + ')\n')
1456  ConfgFile.write('MeasDCI2.set(' + str(MeasDCI2.get()) + ')\n')
1457  ConfgFile.write('MeasMinI2.set(' + str(MeasMinI2.get()) + ')\n')
1458  ConfgFile.write('MeasMaxI2.set(' + str(MeasMaxI2.get()) + ')\n')
1459  ConfgFile.write('MeasMidI2.set(' + str(MeasMidI2.get()) + ')\n')
1460  ConfgFile.write('MeasPPI2.set(' + str(MeasPPI2.get()) + ')\n')
1461  ConfgFile.write('MeasRMSI2.set(' + str(MeasRMSI2.get()) + ')\n')
1462  ConfgFile.write('MeasDiffBA.set(' + str(MeasDiffBA.get()) + ')\n')
1463  #
1464  ConfgFile.write('MeasAHW.set(' + str(MeasAHW.get()) + ')\n')
1465  ConfgFile.write('MeasALW.set(' + str(MeasALW.get()) + ')\n')
1466  ConfgFile.write('MeasADCy.set(' + str(MeasADCy.get()) + ')\n')
1467  ConfgFile.write('MeasAPER.set(' + str(MeasAPER.get()) + ')\n')
1468  ConfgFile.write('MeasAFREQ.set(' + str(MeasAFREQ.get()) + ')\n')
1469  ConfgFile.write('MeasBHW.set(' + str(MeasBHW.get()) + ')\n')
1470  ConfgFile.write('MeasBLW.set(' + str(MeasBLW.get()) + ')\n')
1471  ConfgFile.write('MeasBDCy.set(' + str(MeasBDCy.get()) + ')\n')
1472  ConfgFile.write('MeasBPER.set(' + str(MeasBPER.get()) + ')\n')
1473  ConfgFile.write('MeasBFREQ.set(' + str(MeasBFREQ.get()) + ')\n')
1474  ConfgFile.write('MeasPhase.set(' + str(MeasPhase.get()) + ')\n')
1475  ConfgFile.write('MeasDelay.set(' + str(MeasDelay.get()) + ')\n')
1476  #
1477  ConfgFile.write('MathTrace.set(' + str(MathTrace.get()) + ')\n')
1478  #
1479  ConfgFile.write('CHAIGainEntry.delete(0,END)\n')
1480  ConfgFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
1481  ConfgFile.write('CHBIGainEntry.delete(0,END)\n')
1482  ConfgFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
1483  ConfgFile.write('CHAIOffsetEntry.delete(0,END)\n')
1484  ConfgFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
1485  ConfgFile.write('CHBIOffsetEntry.delete(0,END)\n')
1486  ConfgFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
1487  # Save strings
1488  ConfgFile.write('UserAString = "' + UserAString + '"\n')
1489  ConfgFile.write('UserALabel = "' + UserALabel + '"\n')
1490  ConfgFile.write('UserBString = "' + UserBString + '"\n')
1491  ConfgFile.write('UserBLabel = "' + UserBLabel + '"\n')
1492  ConfgFile.write('FFTUserWindowString= "' + FFTUserWindowString + '"\n')
1493  ConfgFile.write('DigFilterAString = "' + DigFilterAString + '"\n')
1494  ConfgFile.write('DigFilterBString = "' + DigFilterBString + '"\n')
1495  # save channel AC frequency compensation settings
1496  try:
1497  CHA_TC1.set(float(cha_TC1Entry.get()))
1498  CHA_TC2.set(float(cha_TC2Entry.get()))
1499  CHB_TC1.set(float(chb_TC1Entry.get()))
1500  CHB_TC2.set(float(chb_TC2Entry.get()))
1501  CHA_A1.set(float(cha_A1Entry.get()))
1502  CHA_A2.set(float(cha_A2Entry.get()))
1503  CHB_A1.set(float(chb_A1Entry.get()))
1504  CHB_A2.set(float(chb_A2Entry.get()))
1505  except:
1506  donothing()
1507  ConfgFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
1508  ConfgFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
1509  ConfgFile.write('CHAI_RC_HP.set(' + str(CHAI_RC_HP.get()) + ')\n')
1510  ConfgFile.write('CHBI_RC_HP.set(' + str(CHBI_RC_HP.get()) + ')\n')
1511  ConfgFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
1512  ConfgFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
1513  ConfgFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
1514  ConfgFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
1515  ConfgFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
1516  ConfgFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
1517  ConfgFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
1518  ConfgFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
1519  ConfgFile.write('cha_TC1Entry.delete(0,END)\n')
1520  ConfgFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
1521  ConfgFile.write('cha_TC2Entry.delete(0,END)\n')
1522  ConfgFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
1523  ConfgFile.write('chb_TC1Entry.delete(0,END)\n')
1524  ConfgFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
1525  ConfgFile.write('chb_TC2Entry.delete(0,END)\n')
1526  ConfgFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
1527  ConfgFile.write('cha_A1Entry.delete(0,END)\n')
1528  ConfgFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
1529  ConfgFile.write('cha_A2Entry.delete(0,END)\n')
1530  ConfgFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
1531  ConfgFile.write('chb_A1Entry.delete(0,END)\n')
1532  ConfgFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
1533  ConfgFile.write('chb_A2Entry.delete(0,END)\n')
1534  ConfgFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
1535 
1536  # extra Spectrum stuff
1537  if SpectrumScreenStatus.get() > 0 or IAScreenStatus.get() > 0 or BodeScreenStatus.get() > 0:
1538  ConfgFile.write('SMPfftpwrTwo.set(' + str(SMPfftpwrTwo.get()) + ')\n')
1539  ConfgFile.write('FFTwindow.set(' + str(FFTwindow.get()) + ')\n')
1540  ConfgFile.write('ZEROstuffing.set(' + str(ZEROstuffing.get()) + ')\n')
1541  ConfgFile.write('Vdiv.set(' + str(Vdiv.get()) + ')\n')
1542  #
1543  ConfgFile.write('DBdivindex.set(' + str(DBdivindex.get()) + ')\n')
1544  ConfgFile.write('DBlevel.set(' + str(DBlevel.get()) + ')\n')
1545  # ConfgFile.write('TRACEaverage.set(' + str(TRACEaverage.get()) + ')\n')
1546  ConfgFile.write('CutDC.set(' + str(CutDC.get()) + ')\n')
1547  #
1548  ConfgFile.close()
1549 
1551  global iawindow
1552 
1553  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1554  BSaveConfig(filename)
1555 
1557  global freqwindow
1558 
1559  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1560  BSaveConfig(filename)
1561 
1563  global bodewindow
1564 
1565  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1566  BSaveConfig(filename)
1567 
1569  global root
1570  filename = asksaveasfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1571  BSaveConfig(filename)
1572 
1573 def BLoadConfig(filename):
1574  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1575  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1576  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1577  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1578  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1579  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1580  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1581  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1582  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1583  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1584  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1585  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1586  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1587  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1588  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1589  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1590  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1591  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1592  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1593  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1594  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1595  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1596  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1597  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1598  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1599  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1600  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1601  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1602  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1603  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1604  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1605  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1606  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1607  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1608  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1609  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1610  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1611  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1612  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1613  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1614  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1615  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1616  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1617  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1618  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1619  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1620  global phawindow, PhAca, PhAScreenStatus, PhADisp
1621  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1622  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1623  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
1624  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1625  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1626  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1627  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1628  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1629 
1630  # Read configuration values from file
1631  try:
1632  ConfgFile = open(filename)
1633  for line in ConfgFile:
1634  try:
1635  exec( line.rstrip(), globals(), globals())
1636  #exec( line.rstrip() )
1637  except:
1638  print( "Skipping " + line.rstrip())
1639  ConfgFile.close()
1640  if ScreenWidth < root.winfo_x() or ScreenHeight < root.winfo_y(): # check if main window will be placed off screen?
1641  root.geometry('+0+0')
1642  try:
1643  if ScreenWidth < awgwindow.winfo_x() or ScreenHeight < awgwindow.winfo_y(): # check if AWG window will be placed off screen?
1644  awgwindow.geometry('+0+0')
1645  except:
1646  donothing()
1647  try:
1648  if ScreenWidth < xywindow.winfo_x() or ScreenHeight< xywindow.winfo_y(): # check if XY window will be placed off screen?
1649  xywindow.geometry('+0+0')
1650  except:
1651  donothing()
1652  try:
1653  if ScreenWidth < iawindow.winfo_x() or ScreenHeight < iawindow.winfo_y(): # check if IA window will be placed off screen?
1654  iawindow.geometry('+0+0')
1655  except:
1656  donothing()
1657  try:
1658  if ScreenWidth < freqwindow.winfo_x() or ScreenHeight < freqwindow.winfo_y(): # check if SA window will be placed off screen?
1659  freqwindow.geometry('+0+0')
1660  except:
1661  donothing()
1662  try:
1663  if ScreenWidth < win1.winfo_x() or ScreenHeight < win1.winfo_y(): # check if DAC1 window will be placed off screen?
1664  win1.geometry('+0+0')
1665  except:
1666  donothing()
1667  try:
1668  if ScreenWidth < win2.winfo_x() or ScreenHeight < win2.winfo_y(): # check if DAC2 window will be placed off screen?
1669  win2.geometry('+0+0')
1670  except:
1671  donothing()
1672  try:
1673  if ScreenWidth < minigenwindow.winfo_x() or ScreenHeight < minigenwindow.winfo_y(): # check if mini gen window will be placed off screen?
1674  minigenwindow.geometry('+0+0')
1675  except:
1676  donothing()
1677  try:
1678  if ScreenWidth < muxwindow.winfo_x() or ScreenHeight < muxwindow.winfo_y(): # check if mux window will be placed off screen?
1679  muxwindow.geometry('+0+0')
1680  except:
1681  donothing()
1682  try:
1683  if ScreenWidth < phawindow.winfo_x() or ScreenHeight < phawindow.winfo_y(): # check if PhA window will be placed off screen?
1684  phawindow.geometry('+0+0')
1685  except:
1686  donothing()
1687  try:
1688  if ScreenWidth < bodewindow.winfo_x() or ScreenHeight < bodewindow.winfo_y(): # check if Bode window will be placed off screen?
1689  bodewindow.geometry('+0+0')
1690  except:
1691  donothing()
1692  try:
1693  if ScreenWidth < measurewindow.winfo_x() or ScreenHeight < measurewindow.winfo_y(): # check if Measure window will be placed off screen?
1694  measurewindow.geometry('+0+0')
1695  except:
1696  donothing()
1697  try:
1698  if ScreenWidth < etswindow.winfo_x() or ScreenHeight < etswindow.winfo_y(): # check if ETS window will be placed off screen?
1699  etswindow.geometry('+0+0')
1700  except:
1701  donothing()
1702  if Roll_Mode.get() == 0:
1703  RollBt.config(style="RollOff.TButton",text="Roll-Off")
1704  else:
1705  RollBt.config(style="Roll.TButton",text="Roll-On")
1706  if DevID != "No Device":
1707  BAWGAModeLabel()
1708  BAWGBModeLabel()
1709  BAWGAPhaseDelay()
1710  BAWGBPhaseDelay()
1711  if ColorMode.get() > 0: # White background
1712  # print("White background")
1713  if TRACEwidth.get() < 2:
1714  TRACEwidth.set(2)
1715  COLORtext = "#000000" # 100% black
1716  COLORtrace4 = "#a0a000" # 50% yellow
1717  COLORtraceR4 = "#606000" # 25% yellow
1718  COLORcanvas = "#ffffff" # 100% white
1719  else:
1720  # print("Black background")
1721  COLORcanvas = "#000000" # 100% black
1722  COLORtrace4 = "#ffff00" # 100% yellow
1723  COLORtraceR4 = "#808000" # 50% yellow
1724  COLORtext = "#ffffff" # 100% white
1725  ca.config(background=COLORcanvas)
1726  # Needs to reload from waveform files
1727  if AWGAShape.get()==6:
1728  AWGALoadCSV()
1729  if AWGAShape.get()==13:
1730  AWGALoadWAV()
1731  if AWGBShape.get()==6:
1732  AWGBLoadCSV()
1733  if AWGBShape.get()==13:
1734  AWGBLoadWAV()
1735  # Regenerate waveform from formula
1736  if AWGAShape.get()==10:
1737  AWGAConfigMath()
1738  if AWGBShape.get()==10:
1739  AWGBConfigMath()
1740  if EnableScopeOnly == 0:
1741  UpdateAWGWin()
1742  TimeCheckBox()
1743  XYCheckBox()
1744  FreqCheckBox()
1745  BodeCheckBox()
1746  IACheckBox()
1747  OhmCheckBox()
1748  else:
1749  TimeCheckBox()
1750  XYCheckBox()
1751  UpdateAWGWin()
1752 #
1753  time.sleep(0.05)
1754  ReMakeAWGwaves()
1755  session.end() # Add this to turn off outputs after first time loading a config?
1756  BTime()
1757  except:
1758  print( "Config File Not Found.")
1759 
1760 
1761 def ReMakeAWGwaves(): # re make awg waveforms ib case something changed
1762  global AWGAShape, AWGBShape, BisCompA, AWGAShapeLabel, AWGBShapeLabel
1763  global AWGALength, AWGBLength, AWGAwaveform, AWGBwaveform, EnableScopeOnly
1764 
1765  if AWGAShape.get()==9:
1766  AWGAMakeImpulse()
1767  AWGAShapeLabel.config(text = "Impulse") # change displayed value
1768  elif AWGAShape.get()==11:
1770  AWGAShapeLabel.config(text = "Trapazoid") # change displayed value
1771  elif AWGAShape.get()==15:
1772  AWGAMakeSSQ()
1773  AWGAShapeLabel.config(text = "SSQ Pulse") # change displayed value
1774  elif AWGAShape.get()==16:
1775  AWGAMakeRamp()
1776  AWGAShapeLabel.config(text = "Ramp") # change displayed value
1777  elif AWGAShape.get()==17:
1778  AWGAMakePWMSine()
1779  AWGAShapeLabel.config(text = "PWN Sine") # change displayed value
1780  elif AWGAShape.get()==18:
1782  AWGAShapeLabel.config(text = "Hi Res Sine") # change displayed value
1783  elif AWGAShape.get()==12:
1785  AWGAShapeLabel.config(text = "Up Down Ramp") # change displayed value
1786  elif AWGAShape.get()==14:
1787  AWGAMakeFourier()
1788  AWGAShapeLabel.config(text = "Fourier Series") # change displayed value
1789  elif AWGAShape.get()==19:
1790  AWGAMakeSinc()
1791  AWGAShapeLabel.config(text = "Sinc Pulse") # change displayed value
1792  elif AWGAShape.get()==20:
1793  AWGAMakePulse()
1794  AWGAShapeLabel.config(text = "Pulse") # change displayed value
1795  elif AWGAShape.get()==21:
1796  AWGAMakeFMSine()
1797  AWGAShapeLabel.config(text = "FM Sine") # change displayed value
1798  elif AWGAShape.get()==22:
1799  AWGAMakeAMSine()
1800  AWGAShapeLabel.config(text = "AM Sine") # change displayed value
1801  elif AWGAShape.get()==7:
1802  AWGAMakeUUNoise()
1803  AWGAShapeLabel.config(text = "UU Noise") # change displayed value
1804  elif AWGAShape.get()==8:
1805  AWGAMakeUGNoise()
1806  AWGAShapeLabel.config(text = "UG Noise") # change displayed value
1807  elif AWGAShape.get()==0:
1808  AWGAShapeLabel.config(text = "DC") # change displayed value
1809  elif AWGAShape.get()==2:
1810  AWGAShapeLabel.config(text = "Triangle") # change displayed value
1811  elif AWGAShape.get()==4:
1812  AWGAShapeLabel.config(text = "Square") # change displayed value
1813  elif AWGAShape.get()==3:
1814  AWGAShapeLabel.config(text = "Saw Tooth") # change displayed value
1815  elif AWGAShape.get()==5:
1816  AWGAShapeLabel.config(text = "Starestep") # change displayed value
1817  elif AWGAShape.get()==6:
1818  AWGAShapeLabel.config(text = "CSV File") # change displayed value
1819  elif AWGAShape.get()==13:
1820  AWGAShapeLabel.config(text = "Wav File") # change displayed value
1821  elif AWGAShape.get()==10:
1822  AWGAShapeLabel.config(text = "Math") # change displayed value
1823  else:
1824  AWGAShapeLabel.config(text = "Other Shape") # change displayed value
1825 #
1826  if BisCompA.get() == 1:
1827  SetBCompA()
1828  if AWGBShape.get()==9:
1829  AWGBMakeImpulse()
1830  AWGBShapeLabel.config(text = "Impulse") # change displayed value
1831  elif AWGBShape.get()==11:
1833  AWGBShapeLabel.config(text = "Trapazoid") # change displayed value
1834  elif AWGBShape.get()==15:
1835  AWGBMakeSSQ()
1836  AWGBShapeLabel.config(text = "SSQ Pulse") # change displayed value
1837  elif AWGBShape.get()==16:
1838  AWGBMakeRamp()
1839  AWGBShapeLabel.config(text = "Ramp") # change displayed value
1840  elif AWGBShape.get()==17:
1841  AWGBMakePWMSine()
1842  AWGBShapeLabel.config(text = "PWN Sine") # change displayed value
1843  elif AWGBShape.get()==18:
1845  AWGBShapeLabel.config(text = "Hi Res Sine") # change displayed value
1846  elif AWGBShape.get()==12:
1848  AWGBShapeLabel.config(text = "Up Down Ramp") # change displayed value
1849  elif AWGBShape.get()==14:
1850  AWGBMakeFourier()
1851  AWGBShapeLabel.config(text = "Fourier Series") # change displayed value
1852  elif AWGBShape.get()==19:
1853  AWGBMakeSinc()
1854  AWGBShapeLabel.config(text = "Sinc Pulse") # change displayed value
1855  elif AWGBShape.get()==20:
1856  AWGBMakePulse()
1857  AWGBShapeLabel.config(text = "Pulse") # change displayed value
1858  elif AWGBShape.get()==7:
1859  AWGBMakeUUNoise()
1860  AWGBShapeLabel.config(text = "UU Noise") # change displayed value
1861  elif AWGBShape.get()==8:
1862  AWGBMakeUGNoise()
1863  AWGBShapeLabel.config(text = "UG Noise") # change displayed value
1864  elif AWGBShape.get()==0:
1865  AWGBShapeLabel.config(text = "DC") # change displayed value
1866  elif AWGBShape.get()==2:
1867  AWGBShapeLabel.config(text = "Triangle") # change displayed value
1868  elif AWGBShape.get()==4:
1869  AWGBShapeLabel.config(text = "Square") # change displayed value
1870  elif AWGBShape.get()==3:
1871  AWGBShapeLabel.config(text = "Saw Tooth") # change displayed value
1872  elif AWGBShape.get()==5:
1873  AWGBShapeLabel.config(text = "Starestep") # change displayed value
1874  elif AWGBShape.get()==6:
1875  AWGBShapeLabel.config(text = "CSV File") # change displayed value
1876  elif AWGBShape.get()==13:
1877  AWGBShapeLabel.config(text = "Wav File") # change displayed value
1878  elif AWGBShape.get()==10:
1879  AWGBShapeLabel.config(text = "Math") # change displayed value
1880  else:
1881  AWGBShapeLabel.config(text = "Other Shape") # change displayed value
1882  if EnableScopeOnly == 0:
1883  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
1884  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
1885  UpdateAwgCont()
1886  time.sleep(0.05)
1887 
1889  global iawindow
1890 
1891  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=iawindow)
1892  BLoadConfig(filename)
1893 
1895  global freqwindow
1896 
1897  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=freqwindow)
1898  BLoadConfig(filename)
1899 
1901  global bodewindow
1902 
1903  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=bodewindow)
1904  BLoadConfig(filename)
1905 
1907  global root
1908 
1909  filename = askopenfilename(defaultextension = ".cfg", filetypes=[("Config files", "*.cfg")], parent=root)
1910  BLoadConfig(filename)
1911  UpdateTimeTrace()
1912 
1914  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
1915  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
1916  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
1917  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
1918  global TRIGGERentry, TMsb, Xsignal, AutoCenterA, AutoCenterB
1919  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMX, YsignalMY
1920  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
1921  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
1922  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
1923  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
1924  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
1925  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
1926  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
1927  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
1928  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
1929  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
1930  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
1931  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
1932  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
1933  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
1934  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
1935  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
1936  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
1937  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
1938  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
1939  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
1940  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
1941  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
1942  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
1943  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
1944  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
1945  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
1946  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
1947  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
1948  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
1949  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
1950  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
1951  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
1952  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
1953  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
1954  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
1955  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
1956  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
1957  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
1958  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
1959  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
1960  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
1961  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
1962  global phawindow, PhAca, PhAScreenStatus, PhADisp
1963  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
1964  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
1965  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
1966  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
1967  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
1968  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
1969  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
1970  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
1971  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
1972 
1973  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Script files", "*.txt")], parent=root)
1974  # Read Script commands from file
1975  try:
1976  ConfgFile = open(filename)
1977  for line in ConfgFile:
1978  try:
1979  exec( line.rstrip(), globals(), globals())
1980  # exec( line.rstrip() )
1981  except:
1982  print( "Skipping " + line.rstrip())
1983  showwarning("Syntax Error!",("Syntax Error found in line:\n " + line.rstrip()))
1984  ConfgFile.close()
1985  except:
1986  print( "Config File Not Found.")
1987  showwarning("Warning!","Script File Not Found.")
1988 
1989 
1990 def BgColor():
1991  global COLORtext, COLORcanvas, ColorMode, Bodeca, BodeScreenStatus, PhAca, PhAScreenStatus
1992  global ca, Freqca, SpectrumScreenStatus, XYca, XYScreenStatus, IAca, IAScreenStatus
1993  global COLORtrace4, COLORtraceR4, TRACEwidth
1994 
1995  if ColorMode.get() > 0: # White background
1996  if TRACEwidth.get() < 2:
1997  TRACEwidth.set(2)
1998  COLORtext = "#000000" # 100% black
1999  COLORtrace4 = "#a0a000" # 50% yellow
2000  COLORtraceR4 = "#606000" # 25% yellow
2001  COLORcanvas = "#ffffff" # 100% white
2002  else:
2003  COLORcanvas = "#000000" # 100% black
2004  COLORtrace4 = "#ffff00" # 100% yellow
2005  COLORtraceR4 = "#808000" # 50% yellow
2006  COLORtext = "#ffffff" # 100% white
2007  ca.config(background=COLORcanvas)
2009  if SpectrumScreenStatus.get() > 0:
2010  Freqca.config(background=COLORcanvas)
2012  if XYScreenStatus.get() > 0:
2013  XYca.config(background=COLORcanvas)
2014  UpdateXYScreen()
2015  if PhAScreenStatus.get() > 0:
2016  PhAca.config(background=COLORcanvas)
2017  UpdatePhAScreen()
2018  if IAScreenStatus.get() > 0:
2019  IAca.config(background=COLORcanvas)
2020  UpdateIAScreen()
2021  if BodeScreenStatus.get() > 0:
2022  Bodeca.config(background=COLORcanvas)
2024 
2026  global CANVASwidth, CANVASheight
2027  global COLORtext, MarkerNum, ColorMode
2028  # ask for file name
2029  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")])
2030  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n")
2031  if MarkerNum > 0 or ColorMode.get() > 0:
2032  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2033  else: # temp chnage text corlor to black
2034  COLORtext = "#000000"
2036  # first save postscript file
2037  ca.postscript(file=filename, height=CANVASheight, width=CANVASwidth, colormode='color', rotate=Orient)
2038  # now convert to bit map
2039  # img = Image.open("screen_shot.eps")
2040  # img.save("screen_shot.gif", "gif")
2041  COLORtext = "#ffffff"
2043 
2045  global CANVASwidthXY, CANVASheightXY, xywindow
2046  global COLORtext, MarkerNum, ColorMode, XYca
2047  # ask for file name
2048  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=xywindow)
2049  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=xywindow)
2050  if MarkerNum > 0 or ColorMode.get() > 0:
2051  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2052  else: # temp chnage text corlor to black
2053  COLORtext = "#000000"
2054  UpdateXYScreen()
2055  # first save postscript file
2056  XYca.postscript(file=filename, height=CANVASheightXY, width=CANVASwidthXY, colormode='color', rotate=Orient)
2057  # now convert to bit map
2058  # img = Image.open("screen_shot.eps")
2059  # img.save("screen_shot.gif", "gif")
2060  COLORtext = "#ffffff"
2061  UpdateXYScreen()
2062 
2064  global CANVASwidthIA, CANVASheightIA
2065  global COLORtext, IAca, ColorMode, iawindow
2066  # ask for file name
2067  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=iawindow)
2068  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=iawindow)
2069  if ColorMode.get() > 0:
2070  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2071  else: # temp change text color to black for Black BG
2072  COLORtext = "#000000"
2073  UpdateIAScreen()
2074  # save postscript file
2075  IAca.postscript(file=filename, height=CANVASheightIA, width=CANVASwidthIA, colormode='color', rotate=Orient)
2076  #
2077  COLORtext = "#ffffff"
2078  UpdateIAScreen()
2079 
2081  global CANVASwidthBP, CANVASheightBP
2082  global COLORtext, Bodeca, bodewindow
2083  # ask for file name
2084  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent = bodewindow)
2085  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=bodewindow)
2086  if MarkerNum > 0 or ColorMode.get() > 0:
2087  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2088  else: # temp change text color to black
2089  COLORtext = "#000000"
2091  # save postscript file
2092  Bodeca.postscript(file=filename, height=CANVASheightBP, width=CANVASwidthBP, colormode='color', rotate=Orient)
2093  #
2094  COLORtext = "#ffffff"
2096 
2098  global VBuffA, VBuffB, IBuffA, IBuffB, SAMPLErate
2099 
2100  # open file to save data
2101  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2102  DataFile = open(filename, 'w')
2103  DataFile.write( 'Sample-#, CA-V, CA-I, CB-V, CB-I \n' )
2104  for index in range(len(VBuffA)):
2105  TimePnt = float((index+0.0)/SAMPLErate)
2106  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + ', ' + str(IBuffA[index]) + ', '
2107  + str(VBuffB[index]) + ', ' + str(IBuffB[index]) + '\n')
2108  DataFile.close()
2109 
2111  global SAMPLErate, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2112  # open file to save data
2113  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2114  DataFile = open(filename, 'w')
2115  DataFile.write( 'Sample-#, MuxA, MuxB, MuxC, MuxD \n' )
2116 
2117  for index in range(len(VBuffMA)):
2118  TimePnt = float((index+0.0)/SAMPLErate)
2119  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + ', ' + str(VBuffMB[index]) + ', '
2120  + str(VBuffMC[index]) + ', ' + str(VBuffMD[index]) + '\n')
2121  DataFile.close()
2122 
2123 
2125  global SAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB, VBuffMA, VBuffMB, VBuffMC, VBuffMD
2126 
2127  # ask user for channel to save
2128  Channel = askstring("Choose Channel", "CA-V, CB-V, CA-I, CB-I\n MuxA, MuxB, MuxC, MuxD \n Channel:\n", initialvalue="CA-V")
2129  if (Channel == None): # If Cancel pressed, then None
2130  return
2131  # open file to save data
2132  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
2133  DataFile = open(filename, 'w')
2134  if Channel == "CA-V":
2135  DataFile.write( 'Sample-#, CA-V\n' )
2136  for index in range(len(VBuffA)):
2137  TimePnt = float((index+0.0)/SAMPLErate)
2138  DataFile.write( str(TimePnt) + ', ' + str(VBuffA[index]) + '\n')
2139  elif Channel == "CA-I":
2140  DataFile.write( 'Sample-#, CA-I,\n' )
2141  for index in range(len(IBuffA)):
2142  TimePnt = float((index+0.0)/SAMPLErate)
2143  DataFile.write( str(TimePnt) + ', ' + str(IBuffA[index]) + '\n')
2144  elif Channel == "CB-V":
2145  DataFile.write( 'Sample-#, CB-V\n' )
2146  for index in range(len(VBuffB)):
2147  TimePnt = float((index+0.0)/SAMPLErate)
2148  DataFile.write( str(TimePnt) + ', ' + str(VBuffB[index]) + '\n')
2149  elif Channel == "CB-I":
2150  DataFile.write( 'Sample-#, CB-I,\n' )
2151  for index in range(len(IBuffB)):
2152  TimePnt = float((index+0.0)/SAMPLErate)
2153  DataFile.write( str(TimePnt) + ', ' + str(IBuffB[index]) + '\n')
2154  elif Channel == "MuxA":
2155  DataFile.write( 'Sample-#, MuxA\n' )
2156  for index in range(len(VBuffMA)):
2157  TimePnt = float((index+0.0)/SAMPLErate)
2158  DataFile.write( str(TimePnt) + ', ' + str(VBuffMA[index]) + '\n')
2159  elif Channel == "MuxB":
2160  DataFile.write( 'Sample-#, MuxB\n' )
2161  for index in range(len(VBuffMB)):
2162  TimePnt = float((index+0.0)/SAMPLErate)
2163  DataFile.write( str(TimePnt) + ', ' + str(VBuffMB[index]) + '\n')
2164  elif Channel == "MuxC":
2165  DataFile.write( 'Sample-#, MuxC\n' )
2166  for index in range(len(VBuffMC)):
2167  TimePnt = float((index+0.0)/SAMPLErate)
2168  DataFile.write( str(TimePnt) + ', ' + str(VBuffMC[index]) + '\n')
2169  elif Channel == "MuxD":
2170  DataFile.write( 'Sample-#, MuxD\n' )
2171  for index in range(len(VBuffMD)):
2172  TimePnt = float((index+0.0)/SAMPLErate)
2173  DataFile.write( str(TimePnt) + ', ' + str(VBuffMD[index]) + '\n')
2174  DataFile.close()
2175 
2177  global VBuffA, VBuffB, IBuffA, IBuffB, SHOWsamples
2178 
2179  # Read values from CVS file
2180  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")])
2181  try:
2182  CSVFile = open(filename)
2183  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
2184  CSVFile.seek(0)
2185  csv_f = csv.reader(CSVFile, dialect)
2186  VBuffA = []
2187  VBuffB = []
2188  IBuffA = []
2189  IBuffB = []
2190  SHOWsamples = 0
2191  for row in csv_f:
2192  try:
2193  VBuffA.append(float(row[1]))
2194  IBuffA.append(float(row[2]))
2195  VBuffB.append(float(row[3]))
2196  IBuffB.append(float(row[4]))
2197  SHOWsamples = SHOWsamples + 1
2198  except:
2199  print( 'skipping non-numeric row')
2200  VBuffA = numpy.array(VBuffA)
2201  IBuffA = numpy.array(IBuffA)
2202  VBuffB = numpy.array(VBuffB)
2203  IBuffB = numpy.array(IBuffB)
2204  CSVFile.close()
2205  UpdateTimeTrace()
2206  except:
2207  showwarning("WARNING","No such file found or wrong format!")
2208 
2210 def BHelp():
2211 
2212  url = "https://wiki.analog.com/university/tools/m1k/alice/desk-top-users-guide"
2213  webbrowser.open(url,new=2)
2214 
2215 def BAbout():
2216  global RevDate, SWRev, FWRevOne, HWRevOne, DevID, Version_url
2217 #Version_url = 'https://github.com/analogdevicesinc/alice/releases/download/1.3.8/alice-desktop-1.3-setup.exe'
2218  try:
2219  if sys.version_info[0] == 2:
2220  u = urllib2.urlopen(Version_url)
2221  if sys.version_info[0] == 3:
2222  u = urllib.request.urlopen(Version_url)
2223  meta = u.info()
2224  time_string = str(meta.getheaders("Last-Modified"))
2225  except:
2226  time_string = "Unavailable"
2227  showinfo("About ALICE", "ALICE DeskTop" + SWRev + RevDate + "\n" +
2228  "Last Released Version: " + time_string[7:18] + "\n" +
2229  "ADALM1000 Hardware Rev " + str(HWRevOne) + "\n" +
2230  "Firmware Rev " + str(FWRevOne) + "\n" +
2231  "Board Serial Number " + DevID + "\n" +
2232  "Software is provided as is without any Warranty")
2233 #
2234 
2236  global T1Vline, T2Vline, T1Iline, T2Iline
2237  global Tmathline, TMRline, TXYRline
2238  global T1VRline, T2VRline, T1IRline, T2IRline, TMCVline, TMDVline
2239  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, ShowMath, MathTrace
2240  global MuxScreenStatus, TMARline, TMBRline, TMCRline, TMDRline
2241  global TMAVline, TMBVline, TMCVline, TMDVline
2242  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb
2243  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
2244 
2245  if ShowC1_V.get() == 1:
2246  T1VRline = T1Vline # V reference Trace line channel A
2247  if ShowC2_V.get() == 1:
2248  T2VRline = T2Vline # V reference Trace line channel B
2249  if ShowC1_I.get() == 1:
2250  T1IRline = T1Iline # I reference Trace line channel A
2251  if ShowC2_I.get() == 1:
2252  T2IRline = T2Iline # I reference Trace line channel B
2253  if MathTrace.get() > 0:
2254  TMRline = Tmathline # Math reference Trace line
2255  if MuxScreenStatus.get() > 0:
2256  if Show_CBA.get() > 0:
2257  TMARline = TMAVline # V reference Trace line Mux channel A
2258  if Show_CBB.get() > 0:
2259  TMBRline = TMBVline # V reference Trace line Mux channel B
2260  if Show_CBC.get() > 0:
2261  TMCRline = TMCVline # V reference Trace line Mux channel C
2262  if Show_CBD.get() > 0:
2263  TMDRline = TMDVline # V reference Trace line Mux channel D
2264 #
2265 
2267  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY
2268  global XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
2269 
2270  if len(XYlineVA) > 4:
2271  XYRlineVA = XYlineVA
2272  if len(XYlineVB) > 4:
2273  XYRlineVB = XYlineVB
2274  if len(XYlineIA) > 4:
2275  XYRlineIA = XYlineIA
2276  if len(XYlineIB) > 4:
2277  XYRlineIB = XYlineIB
2278  if len(XYlineM) > 4:
2279  XYRlineM = XYlineM
2280  if len(XYlineMX) > 4:
2281  XYRlineMX = XYlineMX
2282  if len(XYlineMY) > 4:
2283  XYRlineMY = XYlineMY
2284 #
2285 
2286 def BSaveCal():
2287  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2288  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2289  global DevID
2290  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2291  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2292  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2293  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2294 
2295  devidstr = DevID[17:31]
2296  filename = devidstr + "_O.cal"
2297  CalFile = open(filename, "w")
2298  #
2299  CalFile.write('CHAVGainEntry.delete(0,END)\n')
2300  CalFile.write('CHAVGainEntry.insert(4, ' + CHAVGainEntry.get() + ')\n')
2301  CalFile.write('CHBVGainEntry.delete(0,END)\n')
2302  CalFile.write('CHBVGainEntry.insert(4, ' + CHBVGainEntry.get() + ')\n')
2303  CalFile.write('CHAVOffsetEntry.delete(0,END)\n')
2304  CalFile.write('CHAVOffsetEntry.insert(4, ' + CHAVOffsetEntry.get() + ')\n')
2305  CalFile.write('CHBVOffsetEntry.delete(0,END)\n')
2306  CalFile.write('CHBVOffsetEntry.insert(4, ' + CHBVOffsetEntry.get() + ')\n')
2307  #
2308  CalFile.write('CHAIGainEntry.delete(0,END)\n')
2309  CalFile.write('CHAIGainEntry.insert(4, ' + CHAIGainEntry.get() + ')\n')
2310  CalFile.write('CHBIGainEntry.delete(0,END)\n')
2311  CalFile.write('CHBIGainEntry.insert(4, ' + CHBIGainEntry.get() + ')\n')
2312  CalFile.write('CHAIOffsetEntry.delete(0,END)\n')
2313  CalFile.write('CHAIOffsetEntry.insert(4, ' + CHAIOffsetEntry.get() + ')\n')
2314  CalFile.write('CHBIOffsetEntry.delete(0,END)\n')
2315  CalFile.write('CHBIOffsetEntry.insert(4, ' + CHBIOffsetEntry.get() + ')\n')
2316  #
2317  # save channel AC frequency compensation settings
2318  try:
2319  CHA_TC1.set(float(cha_TC1Entry.get()))
2320  CHA_TC2.set(float(cha_TC2Entry.get()))
2321  CHB_TC1.set(float(chb_TC1Entry.get()))
2322  CHB_TC2.set(float(chb_TC2Entry.get()))
2323  CHA_A1.set(float(cha_A1Entry.get()))
2324  CHA_A2.set(float(cha_A2Entry.get()))
2325  CHB_A1.set(float(chb_A1Entry.get()))
2326  CHB_A2.set(float(chb_A2Entry.get()))
2327  except:
2328  donothing()
2329  CalFile.write('CHA_RC_HP.set(' + str(CHA_RC_HP.get()) + ')\n')
2330  CalFile.write('CHB_RC_HP.set(' + str(CHB_RC_HP.get()) + ')\n')
2331  CalFile.write('CHA_TC1.set(' + str(CHA_TC1.get()) + ')\n')
2332  CalFile.write('CHA_TC2.set(' + str(CHA_TC2.get()) + ')\n')
2333  CalFile.write('CHB_TC1.set(' + str(CHB_TC1.get()) + ')\n')
2334  CalFile.write('CHB_TC2.set(' + str(CHB_TC2.get()) + ')\n')
2335  CalFile.write('CHA_A1.set(' + str(CHA_A1.get()) + ')\n')
2336  CalFile.write('CHA_A2.set(' + str(CHA_A2.get()) + ')\n')
2337  CalFile.write('CHB_A1.set(' + str(CHB_A1.get()) + ')\n')
2338  CalFile.write('CHB_A2.set(' + str(CHB_A2.get()) + ')\n')
2339  CalFile.write('cha_TC1Entry.delete(0,END)\n')
2340  CalFile.write('cha_TC1Entry.insert(4, ' + str(CHA_TC1.get()) + ')\n')
2341  CalFile.write('cha_TC2Entry.delete(0,END)\n')
2342  CalFile.write('cha_TC2Entry.insert(4, ' + str(CHA_TC2.get()) + ')\n')
2343  CalFile.write('chb_TC1Entry.delete(0,END)\n')
2344  CalFile.write('chb_TC1Entry.insert(4, ' + str(CHB_TC1.get()) + ')\n')
2345  CalFile.write('chb_TC2Entry.delete(0,END)\n')
2346  CalFile.write('chb_TC2Entry.insert(4, ' + str(CHB_TC2.get()) + ')\n')
2347  CalFile.write('cha_A1Entry.delete(0,END)\n')
2348  CalFile.write('cha_A1Entry.insert(4, ' + str(CHA_A1.get()) + ')\n')
2349  CalFile.write('cha_A2Entry.delete(0,END)\n')
2350  CalFile.write('cha_A2Entry.insert(4, ' + str(CHA_A2.get()) + ')\n')
2351  CalFile.write('chb_A1Entry.delete(0,END)\n')
2352  CalFile.write('chb_A1Entry.insert(4, ' + str(CHB_A1.get()) + ')\n')
2353  CalFile.write('chb_A2Entry.delete(0,END)\n')
2354  CalFile.write('chb_A2Entry.insert(4, ' + str(CHB_A2.get()) + ')\n')
2355 
2356  CalFile.close()
2357 
2358 def BLoadCal():
2359  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
2360  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
2361  global DevID
2362  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
2363  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
2364  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
2365  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
2366 
2367  devidstr = DevID[17:31]
2368  filename = devidstr + "_O.cal"
2369  try:
2370  CalFile = open(filename)
2371  for line in CalFile:
2372  exec( line.rstrip() )
2373  CalFile.close()
2374  except:
2375  print( "Cal file for this device not found")
2376 
2378  global UserAString, UserALabel, MeasUserA
2379 
2380  TempString = UserALabel
2381  UserALabel = askstring("Measurement Label", "Current Label: " + UserALabel + "\n\nNew Label:\n", initialvalue=UserALabel)
2382  if (UserALabel == None): # If Cancel pressed, then None
2383  MeasUserA.set(0)
2384  UserALabel = TempString
2385  return
2386  TempString = UserAString
2387  UserAString = askstring("Measurement Formula", "Current Formula: " + UserAString + "\n\nNew Formula:\n", initialvalue=UserAString)
2388  if (UserAString == None): # If Cancel pressed, then None
2389  MeasUserA.set(0)
2390  UserAString = TempString
2391  return
2392  MeasUserA.set(1)
2393 
2395  global UserBString, UserBLabel, MeasUserB
2396 
2397  TempString = UserBLabel
2398  UserBLabel = askstring("Measurement Label", "Current Label: " + UserBLabel + "\n\nNew Label:\n", initialvalue=UserBLabel)
2399  if (UserBLabel == None): # If Cancel pressed, then None
2400  MeasUserB.set(0)
2401  UserBLabel = TempString
2402  return
2403  TempString = UserBString
2404  UserBString = askstring("Measurement Formula", "Current Formula: " + UserBString + "\n\nNew Formula:\n", initialvalue=UserBString)
2405  if (UserBString == None): # If Cancel pressed, then None
2406  MeasUserB.set(0)
2407  UserBString = TempString
2408  return
2409  MeasUserB.set(1)
2410 #
2411 
2413  global LabelPlotText, PlotLabelText # = "Custom Plot Label"
2414 
2415  TempString = PlotLabelText
2416  PlotLabelText = askstring("Custom Label", "Current Plot Label: " + PlotLabelText + "\n\nNew Label:\n", initialvalue=PlotLabelText)
2417  if (PlotLabelText == None): # If Cancel pressed, then None
2418  LabelPlotText.set(0)
2419  PlotLabelText = TempString
2420  return
2421  LabelPlotText.set(1)
2422 
2424  global RUNstatus, MathScreenStatus, MathWindow, SWRev, RevDate
2425  global MathString, MathUnits, MathXString, MathXUnits, MathYString, MathYUnits
2426  global MathAxis, MathXAxis, MathYAxis, MathTrace
2427  global formentry, unitsentry, axisentry, xformentry, xunitsentry, xaxisentry, yformentry, yunitsentry, yaxisentry
2428  global formlab, xformlab, yformlab, FrameBG
2429  global Mframe1, Mframe2, Mframe3, Mframe4
2430 
2431  if MathScreenStatus.get() == 0:
2432  MathScreenStatus.set(1)
2433  #
2434  MathWindow = Toplevel()
2435  MathWindow.title("Math Formula " + SWRev + RevDate)
2436  MathWindow.resizable(FALSE,FALSE)
2437  MathWindow.protocol("WM_DELETE_WINDOW", DestroyMathScreen)
2438  MathWindow.configure(background=FrameBG)
2439  Mframe1 = LabelFrame(MathWindow, text="Built-in Exp", style="A10T5.TLabelframe") #"A10T5.TLabelframe")
2440  Mframe2 = LabelFrame(MathWindow, text="Math Trace", style="A10T5.TLabelframe")
2441  Mframe3 = LabelFrame(MathWindow, text="X Math Trace", style="A10T6.TLabelframe")
2442  Mframe4 = LabelFrame(MathWindow, text="Y Math Trace", style="A10T7.TLabelframe")
2443  # frame1.grid(row=0, column=0, sticky=W)
2444  #
2445  Mframe1.grid(row = 0, column=0, rowspan=3, sticky=W)
2446  Mframe2.grid(row = 0, column=1, sticky=W)
2447  Mframe3.grid(row = 1, column=1, sticky=W)
2448  Mframe4.grid(row = 2, column=1, sticky=W)
2449  #
2450  # Built in functions
2451  #
2452  mrb1 = Radiobutton(Mframe1, text='none', variable=MathTrace, value=0, command=UpdateTimeTrace)
2453  mrb1.grid(row=0, column=0, sticky=W)
2454  mrb2 = Radiobutton(Mframe1, text='CAV+CBV', variable=MathTrace, value=1, command=UpdateTimeTrace)
2455  mrb2.grid(row=1, column=0, sticky=W)
2456  mrb3 = Radiobutton(Mframe1, text='CAV-CBV', variable=MathTrace, value=2, command=UpdateTimeTrace)
2457  mrb3.grid(row=2, column=0, sticky=W)
2458  mrb4 = Radiobutton(Mframe1, text='CBV-CAV', variable=MathTrace, value=3, command=UpdateTimeTrace)
2459  mrb4.grid(row=3, column=0, sticky=W)
2460  mrb5 = Radiobutton(Mframe1, text='CAI-CBI', variable=MathTrace, value=8, command=UpdateTimeTrace)
2461  mrb5.grid(row=4, column=0, sticky=W)
2462  mrb6 = Radiobutton(Mframe1, text='CBI-CAI', variable=MathTrace, value=9, command=UpdateTimeTrace)
2463  mrb6.grid(row=5, column=0, sticky=W)
2464  mrb7 = Radiobutton(Mframe1, text='CAV*CAI', variable=MathTrace, value=4, command=UpdateTimeTrace)
2465  mrb7.grid(row=6, column=0, sticky=W)
2466  mrb8 = Radiobutton(Mframe1, text='CBV*CBI', variable=MathTrace, value=5, command=UpdateTimeTrace)
2467  mrb8.grid(row=7, column=0, sticky=W)
2468  mrb9 = Radiobutton(Mframe1, text='CAV/CAI', variable=MathTrace, value=6, command=UpdateTimeTrace)
2469  mrb9.grid(row=8, column=0, sticky=W)
2470  mrb10 = Radiobutton(Mframe1, text='CBV/CBI', variable=MathTrace, value=7, command=UpdateTimeTrace)
2471  mrb10.grid(row=9, column=0, sticky=W)
2472  mrb11 = Radiobutton(Mframe1, text='CBV/CAV', variable=MathTrace, value=10, command=UpdateTimeTrace)
2473  mrb11.grid(row=10, column=0, sticky=W)
2474  mrb12 = Radiobutton(Mframe1, text='CBI/CAI', variable=MathTrace, value=11, command=UpdateTimeTrace)
2475  mrb12.grid(row=11, column=0, sticky=W)
2476  mrb13 = Radiobutton(Mframe1, text='Formula', variable=MathTrace, value=12, command=UpdateTimeTrace)
2477  mrb13.grid(row=12, column=0, sticky=W)
2478  #
2479  # Math trace formula sub Mframe2
2480  #
2481  sframe2a = Frame( Mframe2 )
2482  sframe2a.pack(side=TOP)
2483  formlab = Label(sframe2a, text=" Formula ", style= "A10B.TLabel")
2484  formlab.pack(side=LEFT)
2485  formentry = Entry(sframe2a, width=23)
2486  formentry.pack(side=LEFT)
2487  formentry.delete(0,"end")
2488  formentry.insert(0,MathString)
2489  sframe2b = Frame( Mframe2 )
2490  sframe2b.pack(side=TOP)
2491  unitslab = Label(sframe2b, text="Units ", style= "A10B.TLabel")
2492  unitslab.pack(side=LEFT)
2493  unitsentry = Entry(sframe2b, width=6)
2494  unitsentry.pack(side=LEFT)
2495  unitsentry.delete(0,"end")
2496  unitsentry.insert(0,MathUnits)
2497  checkbt = Button(sframe2b, text="Check", command=CheckMathString )
2498  checkbt.pack(side=LEFT)
2499  sframe2c = Frame( Mframe2 )
2500  sframe2c.pack(side=TOP)
2501  axislab = Label(sframe2c, text="Axis ", style= "A10B.TLabel")
2502  axislab.pack(side=LEFT)
2503  axisentry = Entry(sframe2c, width=4)
2504  axisentry.pack(side=LEFT)
2505  axisentry.delete(0,"end")
2506  axisentry.insert(0,MathAxis)
2507  applybt = Button(sframe2c, text="Apply", command=ApplyMathString )
2508  applybt.pack(side=LEFT)
2509  #
2510  # X Math trace formula sub Mframe3
2511  #
2512  sframe3a = Frame( Mframe3 )
2513  sframe3a.pack(side=TOP)
2514  xformlab = Label(sframe3a, text="X Formula ", style= "A10B.TLabel")
2515  xformlab.pack(side=LEFT)
2516  xformentry = Entry(sframe3a, width=23)
2517  xformentry.pack(side=LEFT)
2518  xformentry.delete(0,"end")
2519  xformentry.insert(0, MathXString)
2520  sframe3b = Frame( Mframe3 )
2521  sframe3b.pack(side=TOP)
2522  xunitslab = Label(sframe3b, text="X Units ", style= "A10B.TLabel")
2523  xunitslab.pack(side=LEFT)
2524  xunitsentry = Entry(sframe3b, width=6)
2525  xunitsentry.pack(side=LEFT)
2526  xunitsentry.delete(0,"end")
2527  xunitsentry.insert(0, MathXUnits)
2528  xcheckbt = Button(sframe3b, text="Check", command=CheckMathXString )
2529  xcheckbt.pack(side=LEFT)
2530  sframe3c = Frame( Mframe3 )
2531  sframe3c.pack(side=TOP)
2532  xaxislab = Label(sframe3c, text="X Axis ", style= "A10B.TLabel")
2533  xaxislab.pack(side=LEFT)
2534  xaxisentry = Entry(sframe3c, width=4)
2535  xaxisentry.pack(side=LEFT)
2536  xaxisentry.delete(0,"end")
2537  xaxisentry.insert(0, MathXAxis)
2538  xapplybt = Button(sframe3c, text="Apply", command=ApplyMathXString )
2539  xapplybt.pack(side=LEFT)
2540  #
2541  # Math trace formula sub Mframe4
2542  #
2543  sframe4a = Frame( Mframe4 )
2544  sframe4a.pack(side=TOP)
2545  yformlab = Label(sframe4a, text="Y Formula ", style= "A10B.TLabel")
2546  yformlab.pack(side=LEFT)
2547  yformentry = Entry(sframe4a, width=23)
2548  yformentry.pack(side=LEFT)
2549  yformentry.delete(0,"end")
2550  yformentry.insert(0,MathYString)
2551  sframe4b = Frame( Mframe4 )
2552  sframe4b.pack(side=TOP)
2553  yunitslab = Label(sframe4b, text="Y Units ", style= "A10B.TLabel")
2554  yunitslab.pack(side=LEFT)
2555  yunitsentry = Entry(sframe4b, width=6)
2556  yunitsentry.pack(side=LEFT)
2557  yunitsentry.delete(0,"end")
2558  yunitsentry.insert(0,MathYUnits)
2559  ycheckbt = Button(sframe4b, text="Check", command=CheckMathYString )
2560  ycheckbt.pack(side=LEFT)
2561  sframe4c = Frame( Mframe4 )
2562  sframe4c.pack(side=TOP)
2563  yaxislab = Label(sframe4c, text="Y Axis ", style= "A10B.TLabel")
2564  yaxislab.pack(side=LEFT)
2565  yaxisentry = Entry(sframe4c, width=4)
2566  yaxisentry.pack(side=LEFT)
2567  yaxisentry.delete(0,"end")
2568  yaxisentry.insert(0,MathYAxis)
2569  yapplybt = Button(sframe4c, text="Apply", command=ApplyMathYString )
2570  yapplybt.pack(side=LEFT)
2571 
2572  dismissbutton = Button(MathWindow, text="Dismiss", command=DestroyMathScreen)
2573  dismissbutton.grid(row=3, column=0, sticky=W)
2574 
2575  if RUNstatus.get() > 0:
2576  UpdateTimeTrace()
2577 
2579  global MathScreenStatus, MathWindow
2580 
2581  if MathScreenStatus.get() == 1:
2582  MathScreenStatus.set(0)
2583  MathWindow.destroy()
2584 
2586  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry, formlab
2587  global VBuffA, VBuffB, IBuffA, IBuffB
2588  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2589  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2590  global FFTBuffA, FFTBuffB, FFTwindowshape
2591  global AWGAwaveform, AWGBwaveform
2592  global Show_MathX, Show_MathY
2593  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2594  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2595 
2596  t = 0
2597  TempString = formentry.get()
2598  try:
2599  MathResult = eval(TempString)
2600  formlab.configure(text="Formula ", style= "A10G.TLabel")
2601  except:
2602  formlab.configure(text="Formula ", style= "A10R.TLabel")
2603 
2605  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry, xformlab
2606  global VBuffA, VBuffB, IBuffA, IBuffB
2607  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2608  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2609  global FFTBuffA, FFTBuffB, FFTwindowshape
2610  global AWGAwaveform, AWGBwaveform
2611  global Show_MathX, Show_MathY
2612  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2613  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2614 
2615  t = 0
2616  TempString = xformentry.get()
2617  try:
2618  MathResult = eval(TempString)
2619  xformlab.configure(text="X Formula ", style= "A10G.TLabel")
2620  except:
2621  xformlab.configure(text="X Formula ", style= "A10R.TLabel")
2622 
2624  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry, yformlab
2625  global VBuffA, VBuffB, IBuffA, IBuffB
2626  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
2627  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
2628  global FFTBuffA, FFTBuffB, FFTwindowshape
2629  global AWGAwaveform, AWGBwaveform
2630  global Show_MathX, Show_MathY
2631  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
2632  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
2633 
2634  t = 0
2635  TempString = yformentry.get()
2636  try:
2637  MathResult = eval(TempString)
2638  yformlab.configure(text="Y Formula ", style= "A10G.TLabel")
2639  except:
2640  yformlab.configure(text="Y Formula ", style= "A10R.TLabel")
2641 
2643  global MathString, formentry, MathUnits, unitsentry, MathAxis, axisentry
2644 
2645  MathString = formentry.get()
2646  MathUnits = unitsentry.get()
2647  MathAxis = axisentry.get()
2648 
2650  global MathXString, xformentry, MathXUnits, xunitsentry, MathXAxis, xaxisentry
2651 
2652  MathXString = xformentry.get()
2653  MathXUnits = xunitsentry.get()
2654  MathXAxis = xaxisentry.get()
2655 
2657  global MathYString, yformentry, MathYUnits, yunitsentry, MathYAxis, yaxisentry
2658 
2659  MathYString = yformentry.get()
2660  MathYUnits = yunitsentry.get()
2661  MathYAxis = yaxisentry.get()
2662 
2664  global MarkerLoc, RUNstatus
2665 
2666  TempString = MarkerLoc
2667  MarkerLoc = askstring("Marker Text Location", "Current Marker Text Location: " + MarkerLoc + "\n\nNew Location: (UL, UR, LL, LR)\n", initialvalue=MarkerLoc)
2668  if (MarkerLoc == None): # If Cancel pressed, then None
2669  MarkerLoc = TempString
2670  if RUNstatus.get() == 0: # if not running
2671  UpdateTimeTrace() # Update
2672 
2674  global RUNstatus
2675 
2676 def DoNothing(event):
2677  global RUNstatus
2678 
2680  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
2681 
2682  ShowC1_V.set(1)
2683  ShowC1_I.set(1)
2684  ShowC2_V.set(1)
2685  ShowC2_I.set(1)
2686  if RUNstatus.get() == 0: # if not running
2687  UpdateTimeTrace() # Update
2688 
2690  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, RUNstatus
2691 
2692  ShowC1_V.set(0)
2693  ShowC1_I.set(0)
2694  ShowC2_V.set(0)
2695  ShowC2_I.set(0)
2696  if RUNstatus.get() == 0: # if not running
2697  UpdateTimeTrace() # Update
2698 
2700  global TgEdge
2701 
2702 # TRIGCOND trigcondRisingPositive = 0
2703 # TRIGCOND trigcondFallingNegative = 1
2704 
2706  global TgInput, TRIGGERlevel, TRIGGERentry, RUNstatus
2707  global MaxV1, MinV1, MaxV2, MinV2
2708  global MaxI1, MinI1, MaxI2, MinI2
2709  global MidVMuxA, MidVMuxB, MidVMuxC, MidVMuxD
2710  global ChopMuxMode, ChopTrig
2711  # set new trigger level to mid point of waveform
2712  MidV1 = (MaxV1+MinV1)/2
2713  MidV2 = (MaxV2+MinV2)/2
2714  MidI1 = (MaxI1+MinI1)/2
2715  MidI2 = (MaxI2+MinI2)/2
2716  if (TgInput.get() == 0):
2717  DCString = "0.0"
2718  elif (TgInput.get() == 1 or TgInput.get() == 5):
2719  DCString = ' {0:.2f} '.format(MidV1)
2720  elif (TgInput.get() == 2 ):
2721  DCString = ' {0:.2f} '.format(MidI1)
2722  elif (TgInput.get() == 3 ):
2723  DCString = ' {0:.2f} '.format(MidV2)
2724  elif (TgInput.get() == 4 ):
2725  DCString = ' {0:.2f} '.format(MidI2)
2726 #
2727  if ChopMuxMode.get() > 0:
2728  if ChopTrig.get() == 0:
2729  DCString = "0.0"
2730  if ChopTrig.get() == 1:
2731  DCString = ' {0:.2f} '.format(MidVMuxA)
2732  if ChopTrig.get() == 2:
2733  DCString = ' {0:.2f} '.format(MidVMuxB)
2734  if ChopTrig.get() == 3:
2735  DCString = ' {0:.2f} '.format(MidVMuxC)
2736  if ChopTrig.get() == 4:
2737  DCString = ' {0:.2f} '.format(MidVMuxD)
2738 #
2739  TRIGGERlevel = eval(DCString)
2740  TRIGGERentry.delete(0,END)
2741  TRIGGERentry.insert(4, DCString)
2742  if RUNstatus.get() == 0: # if not running
2743  UpdateTimeTrace() # Update
2744 
2745 
2747  global TgInput
2748 
2749 # if (TgInput.get() == 0):
2750  # no trigger
2751 # elif (TgInput.get() == 1):
2752  # trigger source set to detector of analog in channels
2753  # auto trigger timeout value
2754 # elif (TgInput.get() == 2):
2755  # trigger source set to detector of analog in channels
2756  # 0 disables auto trigger
2757 
2758 def BTriglevel(event):
2759  global TRIGGERlevel, TRIGGERentry, RUNstatus
2760 
2761  # evalute entry string to a numerical value
2762  try:
2763  TRIGGERlevel = float(eval(TRIGGERentry.get()))
2764  except:
2765  TRIGGERentry.delete(0,END)
2766  TRIGGERentry.insert(0, TRIGGERlevel)
2767  # set new trigger level
2768  if RUNstatus.get() == 0: # if not running
2769  UpdateTimeTrace() # Update
2770 
2771 
2772 def BHoldOff(event):
2773  global HoldOff, HoldOffentry, RUNstatus
2774 
2775  try:
2776  HoldOff = float(eval(HoldOffentry.get()))
2777  except:
2778  HoldOffentry.delete(0,END)
2779  HoldOffentry.insert(0, HoldOff)
2780  if RUNstatus.get() == 0: # if not running
2781  UpdateTimeTrace() # Update
2782 # Set Horx possition from entry widget
2783 def BHozPoss(event):
2784  global HozPoss, HozPossentry, RUNstatus
2785 
2786  try:
2787  HozPoss = float(eval(HozPossentry.get()))
2788  except:
2789  HozPossentry.delete(0,END)
2790  HozPossentry.insert(0, HozPoss)
2791  if RUNstatus.get() == 0: # if not running
2792  UpdateTimeTrace() # Update
2793 #
2795  global HozPossentry, TgInput, TMsb
2796 
2797  # get time scale
2798  try:
2799  TIMEdiv = float(eval(TMsb.get()))
2800  except:
2801  TIMEdiv = 0.5
2802  TMsb.delete(0,"end")
2803  TMsb.insert(0,TIMEdiv)
2804  # prevent divide by zero error
2805  if TIMEdiv < 0.0002:
2806  TIMEdiv = 0.01
2807  if TgInput.get() > 0:
2808  HozPoss = -5 * TIMEdiv
2809  HozPossentry.delete(0,END)
2810  HozPossentry.insert(0, HozPoss)
2811 #
2813  global HoldOffentry, HoldOff, TgInput, TMsb
2814 
2815 # get time scale
2816  try:
2817  TIMEdiv = float(eval(TMsb.get()))
2818  except:
2819  TIMEdiv = 0.5
2820  TMsb.delete(0,"end")
2821  TMsb.insert(0,TIMEdiv)
2822  # prevent divide by zero error
2823  if TIMEdiv < 0.0002:
2824  TIMEdiv = 0.01
2825  if TgInput.get() == 0:
2826  HoldOff = HoldOff + TIMEdiv
2827  HoldOffentry.delete(0,END)
2828  HoldOffentry.insert(0, HoldOff)
2829 
2831  global CHB_APosEntry, DCVMuxA
2832 
2833  CHB_APosEntry.delete(0,"end")
2834  CHB_APosEntry.insert(0, ' {0:.2f} '.format(DCVMuxA))
2835 #
2837  global CHB_BPosEntry, DCVMuxB
2838 
2839  CHB_BPosEntry.delete(0,"end")
2840  CHB_BPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxB))
2841 #
2843  global CHB_CPosEntry, DCVMuxC
2844 
2845  CHB_CPosEntry.delete(0,"end")
2846  CHB_CPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxC))
2847 #
2849  global CHD_BPosEntry, DCVMuxD
2850 
2851  CHB_DPosEntry.delete(0,"end")
2852  CHB_DPosEntry.insert(0, ' {0:.2f} '.format(DCVMuxD))
2853 #
2855  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2856 
2857  if MarkerScale.get() != 1:
2858  MarkerScale.set(5)
2859  CHB_Alab.config(style="Rtrace2.TButton")
2860  CHB_Blab.config(style="Strace6.TButton")
2861  CHB_Clab.config(style="Strace7.TButton")
2862  CHB_Dlab.config(style="Strace4.TButton")
2863  else:
2864  MarkerScale.set(0)
2865 #
2867  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2868 
2869  if MarkerScale.get() != 1:
2870  MarkerScale.set(6)
2871  CHB_Alab.config(style="Strace2.TButton")
2872  CHB_Blab.config(style="Rtrace6.TButton")
2873  CHB_Clab.config(style="Strace7.TButton")
2874  CHB_Dlab.config(style="Strace4.TButton")
2875  else:
2876  MarkerScale.set(0)
2877 #
2879  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2880 
2881  if MarkerScale.get() != 1:
2882  MarkerScale.set(7)
2883  CHB_Alab.config(style="Strace2.TButton")
2884  CHB_Blab.config(style="Strace6.TButton")
2885  CHB_Clab.config(style="Rtrace7.TButton")
2886  CHB_Dlab.config(style="Strace4.TButton")
2887  else:
2888  MarkerScale.set(0)
2889 #
2891  global MarkerScale, CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab
2892 
2893  if MarkerScale.get() != 1:
2894  MarkerScale.set(8)
2895  CHB_Alab.config(style="Strace2.TButton")
2896  CHB_Blab.config(style="Strace6.TButton")
2897  CHB_Clab.config(style="Strace7.TButton")
2898  CHB_Dlab.config(style="Rtrace4.TButton")
2899  else:
2900  MarkerScale.set(0)
2901 #
2903  global CHAVPosEntry, DCV1
2904 
2905  CHAVPosEntry.delete(0,"end")
2906  CHAVPosEntry.insert(0, ' {0:.2f} '.format(DCV1))
2907 #
2909  global CHBVPosEntry, DCV2
2910 
2911  CHBVPosEntry.delete(0,"end")
2912  CHBVPosEntry.insert(0, ' {0:.2f} '.format(DCV2))
2913 #
2915  global CHAIPosEntry, DCI1
2916 
2917  CHAIPosEntry.delete(0,"end")
2918  CHAIPosEntry.insert(0, ' {0:.2f} '.format(DCI1))
2919 #
2921  global CHBIPosEntry, DCI2
2922 
2923  CHBIPosEntry.delete(0,"end")
2924  CHBIPosEntry.insert(0, ' {0:.2f} '.format(DCI2))
2925 #
2927  global CHAVPosEntryxy, DCV1
2928 
2929  CHAVPosEntryxy.delete(0,"end")
2930  CHAVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV1))
2931 #
2933  global CHBVPosEntryxy, DCV2
2934 
2935  CHBVPosEntryxy.delete(0,"end")
2936  CHBVPosEntryxy.insert(0, ' {0:.2f} '.format(DCV2))
2937 #
2939  global CHAIPosEntryxy, DCI1
2940 
2941  CHAIPosEntryxy.delete(0,"end")
2942  CHAIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI1))
2943 #
2945  global CHBIPosEntryxy, DCI2
2946 
2947  CHBIPosEntryxy.delete(0,"end")
2948  CHBIPosEntryxy.insert(0, ' {0:.2f} '.format(DCI2))
2949 
2951  global RUNstatus, session, CHA, CHB, devx, AWG_2X, Closed
2952 
2953  RUNstatus.set(0)
2954  Closed = 1
2955  # BSaveConfig("alice-last-config.cfg")
2956  try:
2957  # try to write last config file, Don't crash if running in Write protected space
2958  BSaveConfig("alice-last-config.cfg")
2959  # Put channels in Hi-Z and exit
2960  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
2961  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
2962  devx.set_adc_mux(0) # set ADC mux conf to default
2963  AWG_2X.set(0)
2964  BAWG2X()
2965  CHA.constant(0.0)
2966  CHB.constant(0.0)
2967  devx.set_led(0b001) # Set LED.red on the way out
2968  if session.continuous:
2969  session.end()
2970  except:
2971  donothing()
2972 
2973  root.destroy()
2974  exit()
2975 
2976 def BStart():
2977  global RUNstatus, PowerStatus, devx, PwrBt, DevID, FWRevOne, session, AWGSync
2978  global contloop, discontloop, TIMEdiv, First_Slow_sweep
2979  global TimeDisp, XYDisp, PhADisp, FreqDisp, BodeDisp, IADisp
2980 
2981  if DevID == "No Device":
2982  showwarning("WARNING","No Device Plugged In!")
2983  elif FWRevOne == 0.0:
2984  showwarning("WARNING","Out of data Firmware!")
2985  elif TimeDisp.get() == 0 and XYDisp.get() == 0 and PhADisp.get() == 0 and FreqDisp.get() == 0 and BodeDisp.get() == 0 and IADisp.get() == 0:
2986  showwarning("WARNING","Enable at least one Instrument!")
2987  else:
2988  if PowerStatus == 0:
2989  PowerStatus = 1
2990  PwrBt.config(style="Pwr.TButton",text="PWR-On")
2991  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
2992  if (RUNstatus.get() == 0):
2993  RUNstatus.set(1)
2994  if AWGSync.get() == 0:
2995  session.flush()
2996  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
2997  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
2998  BAWGEnab()
2999  if not session.continuous:
3000  session.start(0)
3001  time.sleep(0.02) # wait awhile here for some reason
3002  elif session.continuous:
3003  session.end()
3004  session.flush()
3005  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
3006  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
3007 
3019  BAWGEnab()
3020  else:
3021  contloop = 0
3022  discontloop = 1
3023  if session.continuous:
3024  session.end() # end continuous session mode
3025 
3026  # UpdateTimeScreen() # Always Update
3027  if TIMEdiv >= 100:
3028  First_Slow_sweep = 0
3029  else:
3030  First_Slow_sweep = 1
3031 #$ Start running Ohmmeter tool
3033  global session, AWGSync
3034 
3035  AWGSync.set(1)
3036  if AWGSync.get() == 0:
3037  session.flush()
3038  if not session.continuous:
3039  session.start(0)
3040  time.sleep(0.02) # wait awhile here for some reason
3041  elif session.continuous:
3042  session.end()
3043  session.flush()
3044  else:
3045  contloop = 0
3046  discontloop = 1
3047  if session.continuous:
3048  session.end() # end continuous session mode
3049 
3050 def BStartIA():
3051  global AWGAFreqEntry, AWGAFreqvalue, Two_X_Sample, FWRevOne
3052 
3053  try:
3054  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
3055  except:
3056  AWGAFreqEntry.delete(0,"end")
3057  AWGAFreqEntry.insert(0, AWGAFreqvalue)
3058  if FWRevOne > 2.16:
3059  if AWGAFreqvalue > 10000.0:
3060  Two_X_Sample.set(1)
3061  else:
3062  Two_X_Sample.set(0)
3063  SetADC_Mux()
3064  IASourceSet()
3065  BStart()
3066 
3068  global IASource, CHA, CHB, AWGAMode, AWGBMode, AWGBIOMode, AWGSync
3069 
3070  if AWGSync.get() == 0: # running in continuous mode
3071  AWGSync.set(1)
3072  if IASource.get() == 1:
3073  CHA.mode = Mode.HI_Z # Put CHA in Hi Z split mode
3074  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3075  AWGAMode.set(2) # Set AWG A to Hi-Z
3076  else:
3077  CHA.mode = Mode.SVMI # Put CHA in Hi Z split mode
3078  CHB.mode = Mode.HI_Z # Put CHB in Hi Z split mode
3079  AWGAMode.set(0) # Set AWG A to SVMI
3080  if AWGBIOMode.get() == 0: # if not in split I/O mode
3081  AWGBMode.set(2) # Set AWG B to Hi-Z
3082 
3083 def BStop():
3084  global RUNstatus, TimeDisp, XYDisp, FreqDisp, IADisp, session, AWGSync
3085  global CHA, CHB, contloop, discontloop
3086 
3087  if (RUNstatus.get() == 1):
3088  # print("Stoping")
3089  RUNstatus.set(0)
3090  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
3091  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
3092  if AWGSync.get() == 0: # running in continuous mode
3093  CHA.constant(0.0)
3094  CHB.constant(0.0)
3095  # print("Stoping continuous mode")
3096  # session.cancel() # cancel continuous session mode while paused
3097  if session.continuous:
3098  #print( "Is Continuous? ", session.continuous)
3099  session.end()
3100  #time.sleep(0.02)
3101  #print( "Is Continuous? ", session.continuous)
3102  else:
3103  contloop = 0
3104  discontloop = 1
3105  session.cancel()
3106 #
3107  if TimeDisp.get() > 0:
3108  UpdateTimeScreen() # Always Update screens as necessary
3109  if XYDisp.get() > 0:
3110  UpdateXYScreen()
3111  if FreqDisp.get() > 0:
3113  if IADisp.get() > 0:
3114  UpdateIAScreen()
3115 
3116 def BPower():
3117  global RUNstatus, PowerStatus, devx, PwrBt
3118 
3119  if (RUNstatus.get() == 1):
3120  BStop()
3121  if PowerStatus == 1:
3122  PowerStatus = 0
3123  PwrBt.config(style="PwrOff.TButton",text="PWR-Off")
3124  devx.ctrl_transfer( 0x40, 0x50, 49, 0, 0, 0, 100) # turn off analog power
3125  else:
3126  PowerStatus = 1
3127  PwrBt.config(style="Pwr.TButton",text="PWR-On")
3128  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
3129 
3130 def BRoll():
3131  global Roll_Mode, RollBt
3132 
3133  if Roll_Mode.get() == 1:
3134  Roll_Mode.set(0)
3135  RollBt.config(style="RollOff.TButton",text="Roll-Off")
3136  else:
3137  Roll_Mode.set(1)
3138  RollBt.config(style="Roll.TButton",text="Roll-On")
3139 
3140 
3141 def BTime():
3142  global TIMEdiv, TMsb, RUNstatus, Two_X_Sample, ETSDisp, FWRevOne, ChopMuxMode
3143  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, AWGSync
3144 
3145  try: # get time scale in mSec/div
3146  TIMEdiv = float(eval(TMsb.get()))
3147  if TIMEdiv < 0.0002:
3148  TIMEdiv = 0.01
3149  TMsb.delete(0,"end")
3150  TMsb.insert(0,TIMEdiv)
3151  except:
3152  TIMEdiv = 0.5
3153  TMsb.delete(0,"end")
3154  TMsb.insert(0,TIMEdiv)
3155  # Switch to 2X sampleling if time scale small enough and not runing ETS
3156  # and not in analog input mux Chop mode.
3157  if ETSDisp.get() == 0 and ChopMuxMode.get() == 0:
3158  Samples_per_div = TIMEdiv * 100.0 # samples per mSec @ base sample rate
3159  if FWRevOne > 2.16:
3160  if Samples_per_div < 20.0:
3161  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
3162  if NumTraces > 2 and AWGSync.get() == 0:
3163  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
3164  BStop()
3165  Two_X_Sample.set(1)
3167  else:
3168  Two_X_Sample.set(0)
3169  SetADC_Mux()
3170  #
3171  if RUNstatus.get() == 0: # if not running
3172  UpdateTimeTrace() # Update
3173 
3175  global CHAsb, RUNstatus, CH1vpdvLevel
3176 
3177  try:
3178  CH1vpdvLevel = float(eval(CHAsb.get()))
3179  except:
3180  CHAsb.delete(0,END)
3181  CHAsb.insert(0, CH1vpdvLevel)
3182  if RUNstatus.get() == 0:
3183  UpdateTimeTrace() # if not running Update
3184 
3186  global CHAIsb, RUNstatus, CH1ipdvLevel
3187 
3188  try:
3189  CH1ipdvLevel = float(eval(CHAIsb.get()))
3190  except:
3191  CHAIsb.delete(0,END)
3192  CHAIsb.insert(0, CH1ipdvLevel)
3193  if RUNstatus.get() == 0:
3194  UpdateTimeTrace() # if not running Update
3195 
3197  global CHBsb, RUNstatus, CH2vpdvLevel
3198 
3199  try:
3200  CH2vpdvLevel = float(eval(CHBsb.get()))
3201  except:
3202  CHBsb.delete(0,END)
3203  CHBsb.insert(0, CH2vpdvLevel)
3204  if RUNstatus.get() == 0:
3205  UpdateTimeTrace() # if not running Update
3206 
3208  global CHBIsb, RUNstatus, CH2ipdvLevel
3209 
3210  try:
3211  CH2ipdvLevel = float(eval(CHBIsb.get()))
3212  except:
3213  CHBIsb.delete(0,END)
3214  CHBIsb.insert(0, CH2ipdvLevel)
3215  if RUNstatus.get() == 0:
3216  UpdateTimeTrace() # if not running Update
3217 
3218 def BOffsetA(event):
3219  global CHAOffset, CHAVPosEntry, RUNstatus
3220 
3221  try:
3222  CHAOffset = float(eval(CHAVPosEntry.get())) # evalute entry string to a numerical value
3223  except:
3224  CHAVPosEntry.delete(0,END)
3225  CHAVPosEntry.insert(0, CHAOffset)
3226  # set new offset level
3227  if RUNstatus.get() == 0:
3228  UpdateTimeTrace() # if not running Update
3229 
3230 def BIOffsetA(event):
3231  global CHAIOffset, CHAIPosEntry, RUNstatus
3232 
3233  try:
3234  CHAIOffset = float(eval(CHAIPosEntry.get())) # evalute entry string to a numerical value
3235  except:
3236  CHAIPosEntry.delete(0,END)
3237  CHAIPosEntry.insert(0, CHAIOffset)
3238  # set new offset level
3239  if RUNstatus.get() == 0:
3240  UpdateTimeTrace() # if not running Update
3241 
3242 def BOffsetB(event):
3243  global CHBOffset, CHBVPosEntry, RUNstatus
3244 
3245  try:
3246  CHBOffset = float(eval(CHBVPosEntry.get())) # evalute entry string to a numerical value
3247  except:
3248  CHBVPosEntry.delete(0,END)
3249  CHBVPosEntry.insert(0, CHBOffset)
3250  # set new offset level
3251  if RUNstatus.get() == 0:
3252  UpdateTimeTrace() # if not running Update
3253 
3254 def BIOffsetB(event):
3255  global CHBIOffset, CHBIPosEntry, RUNstatus
3256 
3257  try:
3258  CHBIOffset = float(eval(CHBIPosEntry.get())) # evalute entry string to a numerical value
3259  except:
3260  CHBIPosEntry.delete(0,END)
3261  CHBIPosEntry.insert(0, CHBIOffset)
3262  # set new offset level
3263  if RUNstatus.get() == 0:
3264  UpdateTimeTrace() # if not running Update
3265 
3267  global TimeDisp, ckb1
3268  if TimeDisp.get() == 1:
3269  ckb1.config(style="Enab.TCheckbutton")
3270  else:
3271  ckb1.config(style="Disab.TCheckbutton")
3272 #
3274  global XYDisp, ckb2
3275  if XYDisp.get() == 1:
3276  ckb2.config(style="Enab.TCheckbutton")
3277  else:
3278  ckb2.config(style="Disab.TCheckbutton")
3279 #
3281  global FreqDisp, ckb3, OOTckb3, OOTScreenStatus
3282  if FreqDisp.get() == 1:
3283  if OOTScreenStatus.get() == 0:
3284  ckb3.config(style="Enab.TCheckbutton")
3285  else:
3286  OOTckb3.config(style="Enab.TCheckbutton")
3287  else:
3288  if OOTScreenStatus.get() == 0:
3289  ckb3.config(style="Disab.TCheckbutton")
3290  else:
3291  OOTckb3.config(style="Disab.TCheckbutton")
3292 #
3294  global BodeDisp, ckb5, AWGSync, OOTckb5, OOTScreenStatus
3295  if BodeDisp.get() == 1:
3296  AWGSync.set(1)
3297  if OOTScreenStatus.get() == 0:
3298  ckb5.config(style="Enab.TCheckbutton")
3299  else:
3300  OOTckb5.config(style="Enab.TCheckbutton")
3301  else:
3302  if OOTScreenStatus.get() == 0:
3303  ckb5.config(style="Disab.TCheckbutton")
3304  else:
3305  OOTckb5.config(style="Disab.TCheckbutton")
3306 #
3308  global IADisp, ckb4, OOTckb4, OOTScreenStatus
3309  if IADisp.get() == 1:
3310  if OOTScreenStatus.get() == 0:
3311  ckb4.config(style="Enab.TCheckbutton")
3312  else:
3313  OOTckb4.config(style="Enab.TCheckbutton")
3314  else:
3315  if OOTScreenStatus.get() == 0:
3316  ckb4.config(style="Disab.TCheckbutton")
3317  else:
3318  OOTckb4.config(style="Disab.TCheckbutton")
3319 #
3321  global PhADisp, Phckb, OOTphckb, OOTScreenStatus
3322  if PhADisp.get() == 1:
3323  if OOTScreenStatus.get() == 0:
3324  phckb.config(style="Enab.TCheckbutton")
3325  else:
3326  OOTphckb.config(style="Enab.TCheckbutton")
3327  else:
3328  if OOTScreenStatus.get() == 0:
3329  phckb.config(style="Disab.TCheckbutton")
3330  else:
3331  OOTphckb.config(style="Disab.TCheckbutton")
3332 #
3334  global OhmDisp, ckb6, OOTckb6, OOTScreenStatus
3335  if OhmDisp.get() == 1:
3336  if OOTScreenStatus.get() == 0:
3337  ckb6.config(style="Enab.TCheckbutton")
3338  else:
3339  OOTckb6.config(style="Enab.TCheckbutton")
3340  else:
3341  if OOTScreenStatus.get() == 0:
3342  ckb6.config(style="Disab.TCheckbutton")
3343  else:
3344  OOTckb6.config(style="Disab.TCheckbutton")
3345 #
3347  global ETSDisp, enb1
3348  if ETSDisp.get() == 1:
3349  enb1.config(style="Enab.TCheckbutton")
3350  else:
3351  try:
3352  enb1.config(style="Disab.TCheckbutton")
3353  except:
3354  donothing()
3355 # ========================= Main routine ====================================
3356 
3358  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp, SpectrumScreenStatus, HWRevOne
3359  global PhADisp, IADisp, IAScreenStatus, CutDC, DevOne, AWGBMode, MuxEnb, BodeScreenStatus, BodeDisp
3360  global MuxScreenStatus, VBuffA, VBuffB, MuxSync, AWGBIOMode
3361  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD, MuxChan
3362  global ShowC1_V, ShowC2_V, ShowC2_I, SMPfft
3363  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3364  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3365  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3366  global SV1, SI1, SV2, SI2, SVA_B, Closed
3367  global FregPoint, FBins, FStep, TRACEaverage
3368  # Analog Mux channel measurement variables
3369  global TRACEresetTime, TRACEmodeTime, TgInput, SettingsStatus, TRIGGERsample
3370  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode
3371  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3372  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3373  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3374  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3375  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3376 
3377  while (Closed == 0): # Main loop
3378  # RUNstatus = 1 : Open Acquisition
3379  if (RUNstatus.get() == 1) or (RUNstatus.get() == 2):
3380  if SettingsStatus.get() == 1:
3381  SettingsUpdate() # Make sure current entries in Settings controls are up to date
3382  if TimeDisp.get() > 0 or XYDisp.get() > 0 or PhADisp.get() > 0:
3383  if MuxScreenStatus.get() == 0:
3384  MuxChan = -1
3385  Analog_Time_In()
3386  else:
3387  MuxChan = 0
3388  if DualMuxMode.get() == 1: # force split I/O mode if dual mux mode set
3389  AWGAIOMode.set(1)
3390  AWGBIOMode.set(1)
3391  ShowC1_V.set(0) # force A voltage trace off
3392  ShowC2_V.set(0) # force B voltage trace off
3393  if HWRevOne == "D" :
3394  # force channel B to always be in High-Z mode for Rev D hardware or if not in split I/O mode
3395  AWGBMode.set(2)
3396  if AWGBIOMode.get() == 0: # if not in split I/O mode
3397  ShowC2_I.set(0) # no need to show CH-B current
3398  if MuxEnb.get() == 1:
3399  PIO2 = 0x51
3400  else:
3401  PIO2 = 0x50
3402  if MuxSync.get() == 0:
3403  PIO3 = 0x51
3404  PIO3x = 0x50
3405  else:
3406  PIO3 = 0x50
3407  PIO3x = 0x51
3408  #
3409  if ChopMuxMode.get() == 0: # do this if in alternate sweep mode
3410  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3411  TRACEresetTime = True # Clear the memory for averaging
3412  if Show_CBA.get() == 1:
3413  MuxChan = 0
3414  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3415  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3416  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO enable
3417  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to 1 sync pulse for sweep start
3418  time.sleep(0.002)
3419  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3420  if TRACEmodeTime.get() == 1:
3421  if TRACEresetTime == True:
3422  TRACEresetTime = False
3423  # Save previous trace in memory for average trace
3424  VmemoryMuxA = VBuffMA
3425  Analog_Time_In()
3426  if Show_CBB.get() == 1:
3427  MuxChan = 1
3428  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3429  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3430  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3431  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3432  time.sleep(0.002)
3433  devx.ctrl_transfer(0x40, PIO3x, 3, 0, 0, 0, 100) # set PIO 3 to return value
3434  if TRACEmodeTime.get() == 1:
3435  if TRACEresetTime == True:
3436  TRACEresetTime = False
3437  # Save previous trace in memory for average trace
3438  VmemoryMuxB = VBuffMB
3439  Analog_Time_In()
3440  if Show_CBC.get() == 1:
3441  MuxChan = 2
3442  if DualMuxMode.get() == 1:
3443  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3444  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3445  else:
3446  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3447  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3448  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3449  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3450  time.sleep(0.002)
3451  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3452  if TRACEmodeTime.get() == 1:
3453  if TRACEresetTime == True:
3454  TRACEresetTime = False
3455  # Save previous trace in memory for average trace
3456  VmemoryMuxC = VBuffMC
3457  Analog_Time_In()
3458  if Show_CBD.get() == 1:
3459  MuxChan = 3
3460  if DualMuxMode.get() == 1:
3461  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 to 0
3462  devx.ctrl_transfer(0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 1 to 0
3463  else:
3464  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 to 1
3465  devx.ctrl_transfer(0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 1 to 1
3466  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO 2 to 0
3467  devx.ctrl_transfer(0x40, PIO3, PIO_3, 0, 0, 0, 100) # set PIO 3 to sync pulse for sweep start
3468  time.sleep(0.002)
3469  devx.ctrl_transfer(0x40, PIO3x, PIO_3, 0, 0, 0, 100) # set PIO 3 to return value
3470  if TRACEmodeTime.get() == 1:
3471  if TRACEresetTime == True:
3472  TRACEresetTime = False
3473  # Save previous trace in memory for average trace
3474  VmemoryMuxD = VBuffMD
3475  Analog_Time_In()
3476  if Show_CBA.get() == 0 and Show_CBB.get() == 0 and Show_CBC.get() == 0 and Show_CBD.get() == 0 and ShowC1_V.get() == 1:
3477  Analog_Time_In()
3478  else: # do this if in Chop mode
3479  MuxChan = 0
3480  devx.ctrl_transfer(0x40, PIO2, PIO_2, 0, 0, 0, 100) # set PIO_2 enable control
3481  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
3482  TRACEresetTime = True # Clear the memory for averaging
3483  elif TRACEmodeTime.get() == 1:
3484  if TRACEresetTime == True:
3485  TRACEresetTime = False
3486  # Save previous traces in memory for average trace
3487  VmemoryMuxA = VBuffMA
3488  VmemoryMuxB = VBuffMB
3489  VmemoryMuxC = VBuffMC
3490  VmemoryMuxD = VBuffMD
3491  Analog_Time_In()
3492  if (FreqDisp.get() > 0 and SpectrumScreenStatus.get() == 1) or (IADisp.get() > 0 and IAScreenStatus.get() == 1) or (BodeDisp.get() > 0 and BodeScreenStatus.get() == 1):
3493  if IADisp.get() > 0 or BodeDisp.get() > 0:
3494  CutDC.set(1) # remove DC portion of waveform
3495  AWGSync.set(1) # Impedance analyzer and Bode plotter must be run in discontinuous mode
3496  if BodeDisp.get() > 0:
3497  if LoopNum.get() <= len(FStep):
3498  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
3499  if FregPoint < 100.0:
3500  SMPfft = 16384
3501  elif FregPoint < 500.0:
3502  SMPfft = 8192
3503  elif FregPoint < 2000.0:
3504  SMPfft = 4096
3505  else:
3506  SMPfft = 2048
3507  if Two_X_Sample.get() > 0 and FregPoint < 2000.0:
3508  SMPfft = SMPfft * 2
3509 
3510  Analog_Freq_In()
3511  elif OhmRunStatus.get() == 1 and OhmDisp.get() == 1:
3512  Ohm_Analog_In()
3513  root.update_idletasks()
3514  root.update()
3515 
3517  global RMode, CHATestVEntry, CHATestREntry, CHA, CHB, devx, OhmA0, OhmA1, discontloop
3518  global AWGAMode, AWGBMode, AWGAShape, AWGSync, AWGBTerm, AWGAOffsetEntry
3519  global AWGAIOMode, AWGBIOMode, Two_X_Sample
3520 
3521 # Do input probe Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3522  try:
3523  InOffA = float(eval(CHAVOffsetEntry.get()))
3524  except:
3525  CHAVOffsetEntry.delete(0,END)
3526  CHAVOffsetEntry.insert(0, InOffA)
3527  try:
3528  InGainA = float(eval(CHAVGainEntry.get()))
3529  except:
3530  CHAVGainEntry.delete(0,END)
3531  CHAVGainEntry.insert(0, InGainA)
3532  try:
3533  InOffB = float(eval(CHBVOffsetEntry.get()))
3534  except:
3535  CHBVOffsetEntry.delete(0,END)
3536  CHBVOffsetEntry.insert(0, InOffB)
3537  try:
3538  InGainB = float(eval(CHBVGainEntry.get()))
3539  except:
3540  CHBVGainEntry.delete(0,END)
3541  CHBVGainEntry.insert(0, InGainB)
3542  try:
3543  CurOffA = float(CHAIOffsetEntry.get())
3544  except:
3545  CurOffA = 0.0
3546  try:
3547  CurOffB = float(CHBIOffsetEntry.get())
3548  except:
3549  CurOffB = 0.0
3550  try:
3551  CurGainA = float(CHAIGainEntry.get())
3552  except:
3553  CurGainA = 1.0
3554  try:
3555  CurGainB = float(CHBIGainEntry.get())
3556  except:
3557  CurGainB = 1.0
3558  try:
3559  chatestv = float(eval(CHATestVEntry.get()))
3560  if chatestv > 5.0:
3561  chatestv = 5.0
3562  CHATestVEntry.delete(0,END)
3563  CHATestVEntry.insert(0, chatestv)
3564  except:
3565  CHATestVEntry.delete(0,END)
3566  CHATestVEntry.insert(0, chatestv)
3567  try:
3568  chatestr = float(eval(CHATestREntry.get()))
3569  except:
3570  CHATestREntry.delete(0,END)
3571  CHATestREntry.insert(0, chatestr)
3572  #
3573  DCVA0 = DCVB0 = DCIA0 = DCIB0 = 0.0 # initalize measurment variable
3574  RIN = 1000000 # nominal ALM1000 input resistance is 1 Mohm
3575  Two_X_Sample.set(0) # make sure we are in 1V sample rate mode
3576  SetADC_Mux()
3577  # set A and B channels
3578  AWGAMode.set(0) # Set AWG A to SVMI
3579  AWGAShape.set(0) # DC
3580  AWGBMode.set(2) # Set AWG B to Hi-Z
3581  AWGAIOMode.set(0) # turn off Split I/O mode
3582  AWGBIOMode.set(0) # turn off Split I/O mode
3583  AWGAOffsetEntry.delete(0,"end")
3584  AWGAOffsetEntry.insert(0, chatestv)
3585  BAWGAModeLabel()
3586  BAWGBModeLabel() # update AWG labels
3587 
3588  if RMode.get() == 0:
3589  AWGBTerm.set(0)
3590  else:
3591  AWGBTerm.set(1)
3592  #
3593  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3594  if discontloop > 0:
3595  session.flush()
3596  else:
3597  discontloop = 1
3598  time.sleep(0.01)
3599  BAWGEnab()
3600  ADsignal1 = devx.get_samples(210) # get samples for both channel A and B
3601  # time.sleep(1000.0/SHOWsamples)
3602  else: # running in continuous mode
3603  if session.continuous:
3604  ADsignal1 = devx.read(210, -1, True) # get samples for both channel A and B
3605  #
3606  # get_samples returns a list of values for voltage [0] and current [1]
3607  for index in range(200): # calculate average
3608  DCVA0 += ADsignal1[index+10][0][0] # VAdata # Sum for average CA voltage
3609  DCVB0 += ADsignal1[index+10][1][0] # VBdata # Sum for average CB voltage
3610  DCIA0 += ADsignal1[index+10][0][1] # Sum for average CA current
3611  DCIB0 += ADsignal1[index+10][1][1] # Sum for average CB current
3612 
3613  DCVA0 = DCVA0 / 200.0 # calculate average
3614  DCVB0 = DCVB0 / 200.0 # calculate average
3615  DCIA0 = DCIA0 / 200.0 # calculate average
3616  DCIB0 = DCIB0 / 200.0 # calculate average
3617  DCVA0 = (DCVA0 - InOffA) * InGainA
3618  DCVB0 = (DCVB0 - InOffB) * InGainB
3619  DCIA0 = ((DCIA0*1000) - CurOffA) * CurGainA
3620  DCIB0 = ((DCIB0*1000) - CurOffB) * CurGainB
3621  if RMode.get() == 0: # external resistor
3622  DCM = chatestr * (DCVB0/(DCVA0-DCVB0))
3623  DCR = (DCM * RIN) / (RIN - DCM) # correct for channel B input resistance
3624  else: # use internal 50 ohm resistor
3625  DCR = chatestr * ((DCVA0-DCVB0)/DCVB0)
3626  if DCR < 1000:
3627  OhmString = '{0:.2f} '.format(DCR) + "Ohms "# format with 2 decimal places
3628  else:
3629  OhmString = '{0:.3f} '.format(DCR/1000) + "KOhms " # divide by 1000 and format with 3 decimal places
3630  IAString = "Meas " + ' {0:.2f} '.format(DCIA0) + " mA " + ' {0:.2f} '.format(DCVB0) + " V"
3631  OhmA0.config(text = OhmString) # change displayed value
3632  OhmA1.config(text = IAString) # change displayed value
3633 #
3634  time.sleep(0.1)
3635  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
3636 
3639  global TIMEdiv, TMsb, TRACEmodeTime, TRACEresetTime, TRACEaverage
3640  global VBuffMA, VmemoryMuxA, VBuffMB, VmemoryMuxB, VBuffMC, VmemoryMuxC, VBuffMD, VmemoryMuxD
3641  global CHAVOffsetEntry, CHAVGainEntry, CHBVOffsetEntry, CHBVGainEntry
3642  global CHAIOffsetEntry, CHBIOffsetEntry, CHAIGainEntry, CHBIGainEntry
3643  global InOffA, InGainA, InOffB, InGainB
3644  global CurOffA, CurOffB, CurGainA, CurGainB
3645  global PhADisp, PhAScreenStatus, MuxScreenStatus, ChopMuxMode
3646  global First_Slow_sweep, Roll_Mode
3647  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3648 
3649  # get time scale
3650  try:
3651  TIMEdiv = eval(TMsb.get())
3652  except:
3653  TIMEdiv = 0.5
3654  TMsb.delete(0,"end")
3655  TMsb.insert(0,TIMEdiv)
3656  if TIMEdiv < 0.0002:
3657  TIMEdiv = 0.01
3658  #
3659 # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
3660  try:
3661  InOffA = float(eval(CHAVOffsetEntry.get()))
3662  except:
3663  CHAVOffsetEntry.delete(0,END)
3664  CHAVOffsetEntry.insert(0, InOffA)
3665  try:
3666  InGainA = float(eval(CHAVGainEntry.get()))
3667  except:
3668  CHAVGainEntry.delete(0,END)
3669  CHAVGainEntry.insert(0, InGainA)
3670  try:
3671  InOffB = float(eval(CHBVOffsetEntry.get()))
3672  except:
3673  CHBVOffsetEntry.delete(0,END)
3674  CHBVOffsetEntry.insert(0, InOffB)
3675  try:
3676  InGainB = float(eval(CHBVGainEntry.get()))
3677  except:
3678  CHBVGainEntry.delete(0,END)
3679  CHBVGainEntry.insert(0, InGainB)
3680  try:
3681  CurOffA = float(CHAIOffsetEntry.get()) #/1000.0 # convert to Amps # leave in mA
3682  except:
3683  CurOffA = 0.0
3684  try:
3685  CurOffB = float(CHBIOffsetEntry.get())#/1000.0 # convert to Amps
3686  except:
3687  CurOffB = 0.0
3688  try:
3689  CurGainA = float(CHAIGainEntry.get())
3690  except:
3691  CurGainA = 1.0
3692  try:
3693  CurGainB = float(CHBIGainEntry.get())
3694  except:
3695  CurGainB = 1.0
3696 # Dedecide which Fast or Slow sweep routine to call
3697  if Roll_Mode.get() > 0: # 200:
3698  Analog_Roll_time() # rolling trace
3699  else:
3700  First_Slow_sweep = 0
3702 #
3703  if PhADisp.get() > 0 and PhAScreenStatus.get() == 1:
3704  Analog_Phase_In()
3705 #
3706 # Process captured time dmain signals to extract magnitude and phase data
3708  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB
3709  global VBuffMA, VBuffMB, VBuffMC, VBuffMD
3710  global VAresult, VBresult, IAresult, IBresult, VABresult
3711  global PhaseVA, PhaseVB, PhaseIA, PhaseIB, PhaseVAB
3712  global VMAresult, VMBresult,VMCresult, VMDresult
3713  global PhaseVMA, PhaseVMB, PhaseVMC, PhaseVMD
3714  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3715  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3716  global DCVMuxA, DCVMuxB, DCVMuxC, DCVMuxD
3717  global SHOWsamples, SMPfft, hldn, MuxScreenStatus, MuxChan, ChopMuxMode
3718  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
3719  global FFTwindowshape, ZEROstuffing
3720 
3721  if len(VBuffA) < SMPfft: # put up warning to reduce number of FFT Samples or increase Time/Div time base
3723  #showwarning("WARNING","Redude Number of Samples \n Or Increas Time/Div time base.")
3724  #BStop() # Force Stop loop if running
3725  #return
3726  # Do an FFT on captured voltage and current buffer
3727  StartSmp = hldn
3728  StopSmp = hldn + SMPfft
3730  REX = []
3731  PhaseVA = []
3732  PhaseIA = []
3733  PhaseIB = []
3734  # Convert list to numpy array REX for faster Numpy calculations
3735  # Take the first SMPfft samples of VBuffA
3736  REX = numpy.array(VBuffA[StartSmp:StopSmp]-DCV1) # Make a numpy arry of the list
3737 
3738  # Set Analog level display value MAX value is 5 volts for ALM1000
3739  REX = REX / 5.0
3740 
3741  # Do the FFT window function
3742  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3743  # FFT with numpy
3744  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3745  PhaseVA = numpy.angle(ALL, deg=True) # calculate angle
3746  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3747 
3748  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3749  ALL = ALL[0:le] # So take only first half of the array
3750  PhaseVA = PhaseVA[0:le]
3751  Totalcorr = 7.07106 / SMPfft # RMS For VOLTAGE!
3752  VAresult = Totalcorr * ALL
3753  # check to see if analog Mux is being used?
3754  if MuxScreenStatus.get() == 0:
3755  PhaseVB = []
3756  PhaseVAB = []
3757  # Now VB array
3758  REX = numpy.array(VBuffB[StartSmp:StopSmp]-DCV2) # Make a numpy arry of the list
3759 
3760  # Set Analog level display value MAX value is 5 volts for ALM1000
3761  REX = REX / 5.0
3762 
3763  # Do the FFT window function
3764  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3765 
3766  # FFT with numpy
3767  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3768  PhaseVB = numpy.angle(ALL, deg=True) # calculate angle
3769  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3770 
3771  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3772  ALL = ALL[0:le] # So take only first half of the array
3773  PhaseVB = PhaseVB[0:le]
3774  RMScorr = 7.07106 / SMPfft # For rMS VOLTAGE!
3775  VBresult = RMScorr * ALL
3776 
3777  # Now VAB array
3778  REX = numpy.array(VBuffA[StartSmp:StopSmp]-VBuffB[StartSmp:StopSmp]) # Make a numpy arry of the list
3779  REX = REX - (DCV1-DCV2) # cut any remaining DC
3780  # Set Analog level display value MAX value is 5 volts for ALM1000
3781  REX = REX / 5.0
3782 
3783  # Do the FFT window function
3784  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3785 
3786  # FFT with numpy
3787  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3788  PhaseVAB = numpy.angle(ALL, deg=True) # calculate angle
3789  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3790 
3791  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3792  ALL = ALL[0:le] # So take only first half of the array
3793  PhaseVAB = PhaseVAB[0:le]
3794  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3795  VABresult = RMScorr * ALL
3796  else: # Do FFTs on Mux buffers as needed if MuxScreenStatus.get() > 0:
3797  if MuxChan == 0 or ChopMuxMode.get() > 0: #
3798  PhaseVMA = []
3799  # Now VMuxA array
3800  REX = numpy.array(VBuffMA[StartSmp:StopSmp]-DCVMuxA) # Make a numpy arry of the list
3801 
3802  # Set Analog level display value MAX value is 5 volts for ALM1000
3803  REX = REX / 5.0
3804 
3805  # Do the FFT window function
3806  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3807 
3808  # FFT with numpy
3809  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3810  PhaseVMA = numpy.angle(ALL, deg=True) # calculate angle
3811  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3812 
3813  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3814  ALL = ALL[0:le] # So take only first half of the array
3815  PhaseVMA = PhaseVMA[0:le]
3816  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3817  VMAresult = RMScorr * ALL
3818  if MuxChan == 1 or ChopMuxMode.get() > 0: # MuxChan = 1
3819  PhaseVMB = []
3820  # Now VMuxA array
3821  REX = numpy.array(VBuffMB[StartSmp:StopSmp]-DCVMuxB) # Make a numpy arry of the list
3822 
3823  # Set Analog level display value MAX value is 5 volts for ALM1000
3824  REX = REX / 5.0
3825 
3826  # Do the FFT window function
3827  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3828 
3829  # FFT with numpy
3830  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3831  PhaseVMB = numpy.angle(ALL, deg=True) # calculate angle
3832  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3833 
3834  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3835  ALL = ALL[0:le] # So take only first half of the array
3836  PhaseVMB = PhaseVMB[0:le]
3837  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3838  VMBresult = RMScorr * ALL
3839  if MuxChan == 2 or ChopMuxMode.get() > 0: # MuxChan = 2
3840  PhaseVMC = []
3841  # Now VMuxA array
3842  REX = numpy.array(VBuffMC[StartSmp:StopSmp]-DCVMuxC) # Make a numpy arry of the list
3843 
3844  # Set Analog level display value MAX value is 5 volts for ALM1000
3845  REX = REX / 5.0
3846 
3847  # Do the FFT window function
3848  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3849 
3850  # FFT with numpy
3851  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3852  PhaseVMC = numpy.angle(ALL, deg=True) # calculate angle
3853  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3854 
3855  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3856  ALL = ALL[0:le] # So take only first half of the array
3857  PhaseVMC = PhaseVMC[0:le]
3858  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3859  VMCresult = RMScorr * ALL
3860  if MuxChan == 3 or ChopMuxMode.get() > 0: # MuxChan = 3
3861  PhaseVMD = []
3862  # Now VMuxA array
3863  REX = numpy.array(VBuffMD[StartSmp:StopSmp]-DCVMuxD) # Make a numpy arry of the list
3864 
3865  # Set Analog level display value MAX value is 5 volts for ALM1000
3866  REX = REX / 5.0
3867 
3868  # Do the FFT window function
3869  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3870 
3871  # FFT with numpy
3872  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3873  PhaseVMD = numpy.angle(ALL, deg=True) # calculate angle
3874  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3875 
3876  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3877  ALL = ALL[0:le] # So take only first half of the array
3878  PhaseVMD = PhaseVMD[0:le]
3879  RMScorr = 7.07106 / SMPfft # For rms VOLTAGE!
3880  VMDresult = RMScorr * ALL
3881  # Now IA array
3882  REX = numpy.array(IBuffA[StartSmp:StopSmp]) # -DCI1 Make a numpy arry of the list
3883 
3884  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3885  REX = REX / 0.5
3886 
3887  # Do the FFT window function
3888  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3889 
3890  # FFT with numpy
3891  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3892  PhaseIA = numpy.angle(ALL, deg=True) # calculate angle
3893  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3894 
3895  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3896  ALL = ALL[0:le] # So take only first half of the array
3897  PhaseIA = PhaseIA[0:le]
3898  RMScorr = 0.707106 / SMPfft # RMS For current!
3899  IAresult = RMScorr * ALL
3900 
3901  # Now IB array
3902  REX = numpy.array(IBuffB[StartSmp:StopSmp]) # -DCI2 Make a numpy arry of the list
3903 
3904  # Set Analog level display value MAX value is 0.2 amps for ALM1000
3905  REX = REX / 0.5
3906 
3907  # Do the FFT window function
3908  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
3909 
3910  # FFT with numpy
3911  ALL = numpy.fft.fft(REX, n=SMPfft) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
3912  PhaseIB = numpy.angle(ALL, deg=True) # calculate angle
3913  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
3914 
3915  le = int(len(ALL) / 2) # Only half is used, other half is mirror
3916  ALL = ALL[0:le] # So take only first half of the array
3917  PhaseIB = PhaseIB[0:le]
3918  RMScorr = 0.707106 / SMPfft # RMS For current!
3919  IBresult = RMScorr * ALL
3920 #
3921  UpdatePhAAll()
3922 #
3923 # Right now this is a limited attempt to plot rolling sweep.
3925  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
3926  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
3927  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
3928  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
3929  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
3930  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
3931  global CHA, CHB, session, devx, discontloop, contloop
3932  global TRACES, TRACESread, TRACEsize, First_Slow_sweep, Roll_Mode # , ShiftPointer
3933  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
3934  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, GRW
3935  global SAMPLErate, SHOWsamples, MinSamples, MaxSamples, AWGSAMPLErate
3936  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
3937  global SCREENrefresh, DCrefresh
3938  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
3939  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
3940  global SV1, SI1, SV2, SI2, SVA_B
3941  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
3942  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
3943  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
3944  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
3945  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
3946  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
3947  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
3948  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
3949  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
3950  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
3951  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
3952  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
3953  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
3954  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode
3955  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
3956  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
3957  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
3958  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
3959  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
3960  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
3961  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
3962 
3963  # Starting acquisition
3964  DCVA0 = DCVB0 = DCIA0 = DCIB0= 0.0 # initalize measurment variable
3965  #
3966  NumSamples = 10 # int(SAMPLErate/TIMEdiv)
3967  if First_Slow_sweep == 0:
3968  VBuffA = numpy.ones(GRW)
3969  VBuffB = numpy.ones(GRW)
3970  IBuffA = numpy.ones(GRW)
3971  IBuffB = numpy.ones(GRW)
3972  DBuff0 = numpy.ones(GRW)
3973  DBuff1 = numpy.ones(GRW)
3974  DBuff2 = numpy.ones(GRW)
3975  DBuff3 = numpy.ones(GRW)
3976  First_Slow_sweep = 1
3977  if len(VBuffA) != GRW:
3978  VBuffA = numpy.ones(GRW)
3979  VBuffB = numpy.ones(GRW)
3980  IBuffA = numpy.ones(GRW)
3981  IBuffB = numpy.ones(GRW)
3982  DBuff0 = numpy.ones(GRW)
3983  DBuff1 = numpy.ones(GRW)
3984  DBuff2 = numpy.ones(GRW)
3985  DBuff3 = numpy.ones(GRW)
3986  #
3987  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
3988  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
3989  if discontloop > 0:
3990  session.flush()
3991  else:
3992  discontloop = 1
3993  BAWGEnab()
3994  ADsignal1 = devx.get_samples(NumSamples) # get samples for both channel A and B
3995  # waite to finish then return to open termination
3996  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
3997  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
3998  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
3999  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4000 
4001  else: # running in continuous mode
4002  if session.continuous:
4003  if MuxScreenStatus.get() > 0:
4004  devx.flush(-1, True)
4005  DummySamples = NumSamples*2
4006  if DummySamples < 10000:
4007  DummySamples = 10000
4008  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4009  ADsignal1 = devx.read(NumSamples, -1, True) # True) get samples for both channel A and B
4010  #
4011  else:
4012  ADsignal1 = devx.get_samples(NumSamples) # , True) # get samples for both channel A and B
4013  # Shift one sample
4014 
4019  for index in range(NumSamples): # calculate average
4020  DCVA0 += ADsignal1[index][0][0] # Sum for average CA voltage
4021  DCVB0 += ADsignal1[index][1][0] # Sum for average CB voltage
4022  DCIA0 += ADsignal1[index][0][1] # Sum for average CA current
4023  DCIB0 += ADsignal1[index][1][1] # Sum for average CB current
4024  DCVA0 = DCVA0/(NumSamples) # calculate V average
4025  DCVB0 = DCVB0/(NumSamples) # calculate V average
4026  DCIA0 = DCIA0/(NumSamples) # calculate I average
4027  DCIB0 = DCIB0/(NumSamples) # calculate I average
4028  #
4029  #
4030  DCVA0 = (DCVA0 - InOffA) * InGainA
4031  DCVB0 = (DCVB0 - InOffB) * InGainB
4032  DCIA0 = (DCIA0 - CurOffA) * CurGainA
4033  DCIB0 = (DCIB0 - CurOffB) * CurGainB
4034  DCIA0 = DCIA0 * 1000 # convert to mA
4035  DCIB0 = DCIB0 * 1000 # convert to mA
4036 # next new sample
4037 
4050  VBuffA = shift_buffer(VBuffA, -1, DCVA0)
4051  VBuffB = shift_buffer(VBuffB, -1, DCVB0)
4052  IBuffA = shift_buffer(IBuffA, -1, DCIA0)
4053  IBuffB = shift_buffer(IBuffB, -1, DCIB0)
4054 # Make digital input buffer if that port is an input
4055  if D0.get() == 0:
4056  DBuff0 = shift_buffer(DBuff0, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100))
4057  if D1.get() == 0:
4058  DBuff1 = shift_buffer(DBuff1, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100))
4059  if D2.get() == 0:
4060  DBuff2 = shift_buffer(DBuff2, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100))
4061  if D3.get() == 0:
4062  DBuff3 = shift_buffer(DBuff3, -1, devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100))
4063 # Calculate measurement values
4064  DCV1 = numpy.mean(VBuffA)
4065  DCV2 = numpy.mean(VBuffB)
4066  DCI1 = numpy.mean(IBuffA)
4067  DCI2 = numpy.mean(IBuffB)
4068 # find min and max values
4069  MinV1 = numpy.amin(VBuffA)
4070  MaxV1 = numpy.amax(VBuffA)
4071  MinV2 = numpy.amin(VBuffB)
4072  MaxV2 = numpy.amax(VBuffB)
4073  MinI1 = numpy.amin(IBuffA)
4074  MaxI1 = numpy.amax(IBuffA)
4075  MinI2 = numpy.amin(IBuffB)
4076  MaxI2 = numpy.amax(IBuffB)
4077 # RMS value = square root of average of the data record squared
4078  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA)))
4079  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA)))
4080  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB)))
4081  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB)))
4082  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA-VBuffB)))
4083 #
4084  if TimeDisp.get() > 0:
4085  MakeTimeTrace() # Update the traces
4086  UpdateTimeScreen() # Update the screen
4087  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4088  UpdateXYAll() # Update Data, trace and XY screen
4089  if MeasureStatus.get() > 0:
4091  # update screens
4092 #
4094  global ADsignal1, VBuffMA, VBuffMB, VBuffMC, VBuffMD
4095  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4096  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4097  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4098  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4099  global SHOWsamples, ChopModeFilter
4100 
4101  VBuffMA = [] # Clear the Mux A array
4102  VBuffMB = [] # Clear the Mux B array
4103  VBuffMC = [] # Clear the Mux C array
4104  VBuffMD = [] # Clear the Mux D array
4105  index = 1
4106  while index < SHOWsamples-3: # build arrays VBuffMA, VBuffMB, VBuffMC, VBuffMD
4107  pointer = 0
4108  while pointer < 4:
4109  VBuffMA.append(ADsignal1[index+3][0][0]) # chop AIN into Mux A and B
4110  VBuffMB.append(ADsignal1[index+1][0][0])
4111  VBuffMC.append(ADsignal1[index+3][1][0]) # chop BIN into Mux C and D
4112  VBuffMD.append(ADsignal1[index+1][1][0])
4113  pointer = pointer + 1
4114  index = index + 4
4115  VBuffMA = numpy.array(VBuffMA)
4116  VBuffMB = numpy.array(VBuffMB)
4117  VBuffMC = numpy.array(VBuffMC)
4118  VBuffMD = numpy.array(VBuffMD)
4119  # apply a digital filter to interpolate back to 100 KSPS
4120  VBuffMA = numpy.pad(VBuffMA, (4, 0), "edge")
4121  VBuffMA = numpy.convolve(VBuffMA, ChopModeFilter )
4122  VBuffMA = numpy.roll(VBuffMA, -4)
4123  VBuffMB = numpy.pad(VBuffMB, (4, 0), "edge")
4124  VBuffMB = numpy.convolve(VBuffMB, ChopModeFilter)
4125  VBuffMB = numpy.roll(VBuffMB, -6)
4126  VBuffMC = numpy.pad(VBuffMC, (4, 0), "edge")
4127  VBuffMC = numpy.convolve(VBuffMC, ChopModeFilter )
4128  VBuffMC = numpy.roll(VBuffMC, -4)
4129  VBuffMD = numpy.pad(VBuffMD, (4, 0), "edge")
4130  VBuffMD = numpy.convolve(VBuffMD, ChopModeFilter )
4131  VBuffMD = numpy.roll(VBuffMD, -6)
4132  # calculate waveform scalers
4133  EndSample = SHOWsamples-4
4134  DCVMuxA = numpy.mean(VBuffMA[:EndSample])
4135  MinVMuxA = numpy.amin(VBuffMA[:EndSample])
4136  MaxVMuxA = numpy.amax(VBuffMA[:EndSample])
4137  MidVMuxA = (MaxVMuxA+MinVMuxA)/2.0
4138  PPVMuxA = MaxVMuxA-MinVMuxA
4139 #
4140  DCVMuxB = numpy.mean(VBuffMB[:EndSample])
4141  MinVMuxB = numpy.amin(VBuffMB[:EndSample])
4142  MaxVMuxB = numpy.amax(VBuffMB[:EndSample])
4143  MidVMuxB = (MaxVMuxB+MinVMuxB)/2.0
4144  PPVMuxB = MaxVMuxB-MinVMuxB
4145 #
4146  DCVMuxC = numpy.mean(VBuffMC[:EndSample])
4147  MinVMuxC = numpy.amin(VBuffMC[:EndSample])
4148  MaxVMuxC = numpy.amax(VBuffMC[:EndSample])
4149  MidVMuxC = (MaxVMuxC+MinVMuxC)/2.0
4150  PPVMuxC = MaxVMuxC-MinVMuxC
4151 #
4152  DCVMuxD = numpy.mean(VBuffMD[:EndSample])
4153  MinVMuxD = numpy.amin(VBuffMD[:EndSample])
4154  MaxVMuxD = numpy.amax(VBuffMD[:EndSample])
4155  MidVMuxD = (MaxVMuxD+MinVMuxD)/2.0
4156  PPVMuxD = MaxVMuxD-MinVMuxD
4157  # RMS value = square root of average of the data record squared
4158  SVMuxA = numpy.sqrt(numpy.mean(numpy.square(VBuffMA[:EndSample])))
4159  SVMuxB = numpy.sqrt(numpy.mean(numpy.square(VBuffMB[:EndSample])))
4160  SVMuxC = numpy.sqrt(numpy.mean(numpy.square(VBuffMC[:EndSample])))
4161  SVMuxD = numpy.sqrt(numpy.mean(numpy.square(VBuffMD[:EndSample])))
4162 #
4163 # routine for time scales faster than Slow_Sweep_Limit mSec/Div
4165  global ADsignal1, VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
4166  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
4167  global AWGSync, AWGAMode, AWGBMode, TMsb, HoldOff, HoldOffentry, HozPoss, HozPossentry
4168  global AWGAIOMode, AWGBIOMode, DecimateOption, DualMuxMode, MuxChan
4169  global TRACEresetTime, TRACEmodeTime, TRACEaverage, TRIGGERsample, TgInput, LShift
4170  global CHA, CHB, session, devx, discontloop, contloop, DeBugMode
4171  global TRACES, TRACESread, TRACEsize, TRIGGERsampleAltA, TRIGGERsampleAltB
4172  global RUNstatus, SingleShot, ManualTrigger, TimeDisp, XYDisp, FreqDisp
4173  global TIMEdiv1x, TIMEdiv, hldn, Is_Triggered, Trigger_LPF_length, LPFTrigger
4174  global SAMPLErate, SHOWsamples, SMPfft, MinSamples, MaxSamples, AWGSAMPLErate
4175  global TRACErefresh, AWGScreenStatus, XYScreenStatus, MeasureStatus
4176  global SCREENrefresh, DCrefresh, ETSrecord
4177  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
4178  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
4179  global SV1, SI1, SV2, SI2, SVA_B
4180  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4181  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
4182  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
4183  global InOffA, InGainA, InOffB, InGainB, CurOffA, CurOffB, CurGainA, CurGainB
4184  global DigFiltA, DigFiltB, DFiltACoef, DFiltBCoef, DigBuffA, DigBuffB
4185  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
4186  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4187  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4188  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4189  global VAets, VBets, Samples_Cycle, MulX, ETSDisp, ETSDir, ETSts, Fmin, FminE, eqivsamplerate
4190  global DivXEntry, FOffEntry, FminDisp, FOff, DivX, FMulXEntry, FBase, MaxETSrecord
4191  global cal, Two_X_Sample, ADC_Mux_Mode, Alternate_Sweep_Mode, Last_ADC_Mux_Mode
4192  global MeasGateLeft, MeasGateRight, MeasGateNum, MeasGateStatus
4193  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, DualMuxMode, ChopMuxMode, ChopTrig
4194  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
4195  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
4196  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
4197  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
4198  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
4199  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
4200  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
4201  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
4202  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
4203 
4204  if TRACEmodeTime.get() == 0 and TRACEresetTime == False:
4205  TRACEresetTime = True # Clear the memory for averaging
4206  elif TRACEmodeTime.get() == 1:
4207  if TRACEresetTime == True:
4208  TRACEresetTime = False
4209  # Save previous trace in memory for average trace
4210  VmemoryA = VBuffA
4211  VmemoryB = VBuffB
4212  ImemoryA = IBuffA
4213  ImemoryB = IBuffB
4214 
4215  try:
4216  HoldOff = float(eval(HoldOffentry.get()))
4217  if HoldOff < 0:
4218  HoldOff = 0
4219  HoldOffentry.delete(0,END)
4220  HoldOffentry.insert(0, HoldOff)
4221  except:
4222  HoldOffentry.delete(0,END)
4223  HoldOffentry.insert(0, HoldOff)
4224 #
4225  try:
4226  HozPoss = float(eval(HozPossentry.get()))
4227  except:
4228  HozPossentry.delete(0,END)
4229  HozPossentry.insert(0, HozPoss)
4230 
4231  hldn = int(HoldOff * SAMPLErate/1000 )
4232  hozpos = int(HozPoss * SAMPLErate/1000 )
4233  if hozpos < 0:
4234  hozpos = 0
4235  twoscreens = int(SAMPLErate * 20.0 * TIMEdiv / 1000.0) # number of samples to acquire, 2 screen widths
4236  onescreen = int(twoscreens/2)
4237  if hldn+hozpos > MaxSamples-twoscreens:
4238  hldn = MaxSamples-twoscreens-hozpos
4239  HoldOffentry.delete(0,END)
4240  HoldOffentry.insert(0, hldn*1000/SAMPLErate)
4241  if ETSDisp.get() > 0:
4242  if TIMEdiv > 0.2:
4243  MaxETSrecord = int(AWGSAMPLErate * 10 * TIMEdiv / 1000.0)
4244  else:
4245  MaxETSrecord = int(AWGSAMPLErate * 20 * TIMEdiv / 1000.0)
4246  if (MaxETSrecord*100) > MaxSamples:
4247  MaxETSrecord = MaxSamples / 100
4248  try:
4249  DivX = float(eval(DivXEntry.get()))
4250  if DivX < 2:
4251  DivX = 2
4252  if DivX > 75:
4253  DivX = 75
4254  DivXEntry.delete(0,END)
4255  DivXEntry.insert(0, DivX)
4256  except:
4257  DivXEntry.delete(0,END)
4258  DivXEntry.insert(0, DivX)
4259  FOff = 25
4260  MulX = (DivX*SAMPLErate)/(100*FOff)
4261  while MulX > MaxETSrecord:
4262  FOff = FOff + 5
4263  MulX = (DivX*SAMPLErate)/(100*FOff)
4264  FOff = 0 - FOff
4265  if DeBugMode > 0:
4266  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
4267  MulXEntry.config(text = SRstring) # change displayed value
4268  SRstring = "Offset = " + str(FOff) + " samples"
4269  FOffEntry.config(text = SRstring) # change displayed value
4270  SHOWsamples = int(MulX * 100)
4271  else:
4272  SHOWsamples = twoscreens + hldn + hozpos
4273  if SHOWsamples > MaxSamples: # or a Max of 100,000 samples
4274  SHOWsamples = MaxSamples
4275  if SHOWsamples < MinSamples: # or a Min of 1000 samples
4276  SHOWsamples = MinSamples
4277  if PhAScreenStatus.get() > 0:
4278  if SHOWsamples < SMPfft:
4279  SHOWsamples = SMPfft + hldn + hozpos
4280  if hozpos >= 0:
4281  TRIGGERsample = hldn
4282  else:
4283  TRIGGERsample = abs(hozpos)
4284  TRIGGERsample = TRIGGERsample + hozpos #
4285 # Starting acquisition
4286  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
4287  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
4288  if discontloop > 0:
4289  session.flush()
4290  else:
4291  discontloop = 1
4292  time.sleep(0.01)
4293  BAWGEnab()
4294  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
4295  # waite to finish then return to open termination
4296  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4297  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4298  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4299  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4300  else: # running in continuous mode
4301  if session.continuous:
4302  if MuxScreenStatus.get() > 0:
4303  devx.flush(-1, True)
4304  DummySamples = SHOWsamples*2
4305  if DummySamples < 20000:
4306  DummySamples = 20000
4307  ADsignal1 = devx.read(DummySamples, -1, True) # do dummy read if in analog mux mode
4308  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
4309  #
4310  else:
4311  ADsignal1 = devx.get_samples(SHOWsamples) # , True) # get samples for both channel A and B
4312  # waite to finish then return to open termination
4313  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
4314  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
4315  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
4316  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
4317  #
4318  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4319  if ADC_Mux_Mode.get() == 0: # VA and VB
4320  VBuffA = [] # Clear the V Buff array for trace A
4321  VBuffB = [] # Clear the V Buff array for trace B
4322  elif ADC_Mux_Mode.get() == 1: # IA and IB
4323  IBuffA = [] # Clear the I Buff array for trace A
4324  IBuffB = [] # Clear the I Buff array for trace B
4325  elif ADC_Mux_Mode.get() == 4: # VA and IA
4326  VBuffA = [] # Clear the V Buff array for trace A
4327  IBuffA = [] # Clear the I Buff array for trace A
4328  elif ADC_Mux_Mode.get() == 5: # VB and IB
4329  VBuffB = [] # Clear the V Buff array for trace B
4330  IBuffB = [] # Clear the I Buff array for trace B
4331  else:
4332  VBuffA = [] # Clear the V Buff array for trace A
4333  IBuffA = [] # Clear the I Buff array for trace A
4334  VBuffB = [] # Clear the V Buff array for trace B
4335  IBuffB = [] # Clear the I Buff array for trace B
4336  increment = 1
4337  # SAMPLErate = 200000 #AWGSAMPLErate
4338  if SHOWsamples >= 20000 and DecimateOption.get() > 0:
4339  increment = 2
4340  SAMPLErate = int(AWGSAMPLErate/increment)
4341  if SHOWsamples >= 40000 and DecimateOption.get() > 0:
4342  increment = 4
4343  SAMPLErate = int(AWGSAMPLErate/increment)
4344  index = 0
4345  if SHOWsamples != len(ADsignal1):
4346  SHOWsamples = len(ADsignal1)
4347 #
4348  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0: # check to see if Mux Chop mode is set
4350 #
4351  while index < SHOWsamples: # build arrays and decimate if needed
4352  if Two_X_Sample.get() == 1 and ADC_Mux_Mode.get() < 6:
4353  if ADC_Mux_Mode.get() == 0: # VA and VB
4354  VBuffA.append(ADsignal1[index][0][0])
4355  VBuffA.append(ADsignal1[index][1][1])
4356  VBuffB.append(ADsignal1[index][0][1])
4357  VBuffB.append(ADsignal1[index][1][0])
4358  if Alternate_Sweep_Mode.get() == 0:
4359  IBuffA.append(0.0) # fill as a place holder
4360  IBuffA.append(0.0) # fill as a place holder
4361  IBuffB.append(0.0) # fill as a place holder
4362  IBuffB.append(0.0) # fill as a place holder
4363  elif ADC_Mux_Mode.get() == 1: # IA and IB
4364  IBuffA.append(ADsignal1[index][0][1])
4365  IBuffA.append(ADsignal1[index][1][0])
4366  IBuffB.append(ADsignal1[index][0][0])
4367  IBuffB.append(ADsignal1[index][1][1])
4368  if Alternate_Sweep_Mode.get() == 0:
4369  VBuffA.append(0.0) # fill as a place holder
4370  VBuffA.append(0.0) # fill as a place holder
4371  VBuffB.append(0.0) # fill as a place holder
4372  VBuffB.append(0.0) # fill as a place holder
4373  elif ADC_Mux_Mode.get() == 2: # VA and IB
4374  VBuffA.append((ADsignal1[index][0][1])/1024.0)
4375  VBuffA.append((ADsignal1[index][1][0])/1024.0)
4376  #
4377  IBuffB.append( ((ADsignal1[index][0][0])/4096.0)-0.5 )
4378  IBuffB.append( ((ADsignal1[index][1][1])/4096.0)-0.5 )
4379  #
4380  if Alternate_Sweep_Mode.get() == 0:
4381  VBuffB.append(0.0) # fill as a place holder
4382  VBuffB.append(0.0) # fill as a place holder
4383  IBuffA.append(0.0) # fill as a place holder
4384  IBuffA.append(0.0) # fill as a place holder
4385  elif ADC_Mux_Mode.get() == 3: # VB and IA
4386  VBuffB.append((ADsignal1[index][0][0])/1024.0)
4387  VBuffB.append((ADsignal1[index][1][1])/1024.0)
4388  #
4389  IBuffA.append( ((ADsignal1[index][0][1])/4096.0)-0.5 )
4390  IBuffA.append( ((ADsignal1[index][1][0])/4096.0)-0.5 )
4391  #
4392  if Alternate_Sweep_Mode.get() == 0:
4393  VBuffA.append(0.0) # fill as a place holder
4394  VBuffA.append(0.0) # fill as a place holder
4395  IBuffB.append(0.0) # fill as a place holder
4396  IBuffB.append(0.0) # fill as a place holder
4397  elif ADC_Mux_Mode.get() == 4: # VA and IA
4398  VBuffA.append(ADsignal1[index][0][0])
4399  VBuffA.append(ADsignal1[index][1][1])
4400  IBuffA.append(ADsignal1[index][0][1])
4401  IBuffA.append(ADsignal1[index][1][0])
4402  if Alternate_Sweep_Mode.get() == 0:
4403  VBuffB.append(0.0) # fill as a place holder
4404  VBuffB.append(0.0) # fill as a place holder
4405  IBuffB.append(0.0) # fill as a place holder
4406  IBuffB.append(0.0) # fill as a place holder
4407  elif ADC_Mux_Mode.get() == 5: # VB and IB
4408  VBuffB.append(ADsignal1[index][0][1])
4409  VBuffB.append(ADsignal1[index][1][0])
4410  IBuffB.append(ADsignal1[index][0][0])
4411  IBuffB.append(ADsignal1[index][1][1])
4412  if Alternate_Sweep_Mode.get() == 0:
4413  VBuffA.append(0.0) # fill as a place holder
4414  VBuffA.append(0.0) # fill as a place holder
4415  IBuffA.append(0.0) # fill as a place holder
4416  IBuffA.append(0.0) # fill as a place holder
4417  else:
4418  VBuffA.append(ADsignal1[index][0][0])
4419  IBuffA.append(ADsignal1[index][0][1])
4420  VBuffB.append(ADsignal1[index][1][0])
4421  IBuffB.append(ADsignal1[index][1][1])
4422  index = index + increment
4423 #
4424  if Alternate_Sweep_Mode.get() == 1 and Two_X_Sample.get() == 1:
4425  if len(VBuffA) < 4:
4426  index = 0
4427  while index < SHOWsamples:
4428  VBuffA.append(0.0) # fill as a place holder
4429  index = index + increment
4430  if len(VBuffB) < 4:
4431  index = 0
4432  while index < SHOWsamples:
4433  VBuffB.append(0.0) # fill as a place holder
4434  index = index + increment
4435  if len(IBuffA) < 4:
4436  index = 0
4437  while index < SHOWsamples:
4438  IBuffA.append(0.0) # fill as a place holder
4439  index = index + increment
4440  if len(IBuffB) < 4:
4441  index = 0
4442  while index < SHOWsamples:
4443  IBuffB.append(0.0) # fill as a place holder
4444  index = index + increment
4445 #
4446  if ADC_Mux_Mode.get() == 0: # VA and VB
4447  VBuffA = numpy.array(VBuffA)
4448  VBuffB = numpy.array(VBuffB)
4449  VBuffA = (VBuffA - InOffA) * InGainA
4450  VBuffB = (VBuffB - InOffB) * InGainB
4451  ADC_Mux_Mode.set(1) # switch mode
4452  Last_ADC_Mux_Mode = 0
4453  elif ADC_Mux_Mode.get() == 1: # IA and IB
4454  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4455  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4456  IBuffA = (IBuffA - CurOffA) * CurGainA
4457  IBuffB = (IBuffB - CurOffB) * CurGainB
4458  ADC_Mux_Mode.set(Last_ADC_Mux_Mode) # switch mode
4459  elif ADC_Mux_Mode.get() == 4: # VA and IA
4460  VBuffA = numpy.array(VBuffA)
4461  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4462  IBuffA = (IBuffA - CurOffA) * CurGainA
4463  VBuffA = (VBuffA - InOffA) * InGainA
4464  ADC_Mux_Mode.set(1) # switch mode
4465  Last_ADC_Mux_Mode = 4
4466  elif ADC_Mux_Mode.get() == 5: # VB and IB
4467  VBuffB = numpy.array(VBuffB)
4468  VBuffB = (VBuffB - InOffB) * InGainB
4469  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4470  IBuffB = (IBuffB - CurOffB) * CurGainB
4471  ADC_Mux_Mode.set(1) # switch mode
4472  Last_ADC_Mux_Mode = 5
4473  SetADC_Mux()
4474  #
4475  else:
4476  VBuffA = numpy.array(VBuffA)
4477  VBuffB = numpy.array(VBuffB)
4478  IBuffA = numpy.array(IBuffA) * 1000 # convert to mA
4479  IBuffB = numpy.array(IBuffB) * 1000 # convert to mA
4480  VBuffA = (VBuffA - InOffA) * InGainA
4481  VBuffB = (VBuffB - InOffB) * InGainB
4482  IBuffA = (IBuffA - CurOffA) * CurGainA
4483  IBuffB = (IBuffB - CurOffB) * CurGainB
4484  TRACESread = 2
4485  SHOWsamples = len(VBuffA)
4486 # temp ETS calculations
4487  if ETSDisp.get() > 0:
4488  baseFreq = SAMPLErate/DivX
4489  #
4490  VAets = []
4491  VBets = []
4492  IAets = []
4493  IBets = []
4494  index = 0
4495  try:
4496  FMul = float(eval(FminEntry.get()))
4497  if FMul < 1:
4498  FMul = 1
4499  FMulXEntry.delete(0,END)
4500  FMulXEntry.insert(0, int(FMul))
4501  if FMul > 75:
4502  FMul = 75
4503  FMulXEntry.delete(0,END)
4504  FMulXEntry.insert(0, int(FMul))
4505  except:
4506  FMulXEntry.delete(0,END)
4507  FMulXEntry.insert(0, int(FMul))
4508  Fmin = baseFreq * FMul
4509  FminE = float(SAMPLErate + FOff)
4510  Samples_Cycle = SAMPLErate/FminE # calculate number of samples per cycle
4511  # length of record set my Multiplcation factor
4512  tot_cycles = int((MulX*100)/Samples_Cycle)
4513  tot_cycles = tot_cycles + 0.1 # number of cycles in record length
4514  ETSrecord = int((MulX*50)/Samples_Cycle)
4515  if tot_cycles > SHOWsamples:
4516  tot_cycles = SHOWsamples-1
4517  # now sort RT data into ETS sample buffers
4518  while index < SHOWsamples:
4519  Ipart, Dpart = divmod( index*Samples_Cycle, 1)
4520  IndexValue = int(tot_cycles * Dpart)
4521  if IndexValue > SHOWsamples:
4522  IndexValue = SHOWsamples-1
4523  if IndexValue > tot_cycles:
4524  IndexValue = tot_cycles
4525  if ETSDir.get() == 0:
4526  VAets.append(VBuffA[IndexValue])
4527  VBets.append(VBuffB[IndexValue])
4528  IAets.append(IBuffA[IndexValue])
4529  IBets.append(IBuffB[IndexValue])
4530  else:
4531  VAets.append(VBuffA[int(tot_cycles-IndexValue)])
4532  VBets.append(VBuffB[int(tot_cycles-IndexValue)])
4533  IAets.append(IBuffA[int(tot_cycles-IndexValue)])
4534  IBets.append(IBuffB[int(tot_cycles-IndexValue)])
4535  index = index + 1
4536  SHiftFact = 5
4537  TimeCorrection = int(SHiftFact ) # correct for 5 uSec CHB time offset
4538  VBuffA = VAets
4539  VBuffB = VBets
4540  IBuffA = IAets
4541  IBuffB = IBets
4542  VBuffA = numpy.array(VBuffA)
4543  VBuffB = numpy.array(VBuffB)
4544  IBuffA = numpy.array(IBuffA)
4545  IBuffB = numpy.array(IBuffB)
4546  try:
4547  TimeCorrection = int(float(eval(ETSts.get())) * TimeCorrection)
4548  except:
4549  TimeCorrection = SHiftFact
4550  if ETSDir.get() == 0:
4551  VBuffB = numpy.roll(VBuffB, TimeCorrection)
4552  IBuffB = numpy.roll(IBuffB, TimeCorrection)
4553  else:
4554  VBuffB = numpy.roll(VBuffB, TimeCorrection)
4555  IBuffB = numpy.roll(IBuffB, TimeCorrection)
4556  SHOWsamples = twoscreens + hldn + hozpos
4557 # Check if Input channel RC high pass compensation checked
4558  if CHA_RC_HP.get() == 1 or CHAI_RC_HP.get() == 1:
4559  try:
4560  TC1A = float(cha_TC1Entry.get())
4561  if TC1A < 0:
4562  TC1A = 0
4563  cha_TC1Entry.delete(0,END)
4564  cha_TC1Entry.insert(0, TC1A)
4565  except:
4566  TC1A = CHA_TC1.get()
4567  try:
4568  TC2A = float(cha_TC2Entry.get())
4569  if TC2A < 0:
4570  TC2A = 0
4571  cha_TC2Entry.delete(0,END)
4572  cha_TC2Entry.insert(0, TC2A)
4573  except:
4574  TC2A = CHA_TC2.get()
4575  #
4576  try:
4577  Gain1A = float(cha_A1Entry.get())
4578  except:
4579  Gain1A = CHA_A1.get()
4580  try:
4581  Gain2A = float(cha_A2Entry.get())
4582  except:
4583  Gain2A = CHA_A2.get()
4584  #
4585  if len(VBuffA) > 4:
4586  VBuffA = Digital_RC_High_Pass( VBuffA, TC1A, Gain1A )
4587  VBuffA = Digital_RC_High_Pass( VBuffA, TC2A, Gain2A )
4588  if CHAI_RC_HP.get() == 1:
4589  IBuffA = Digital_RC_High_Pass( IBuffA, TC1A, Gain1A )
4590  #IBuffA = Digital_RC_High_Pass( IBuffA, TC2A, Gain2A )
4591  if CHB_RC_HP.get() == 1 or CHBI_RC_HP.get() == 1:
4592  try:
4593  TC1B = float(chb_TC1Entry.get())
4594  if TC1B < 0:
4595  TC1B = 0
4596  chb_TC1Entry.delete(0, END)
4597  chb_TC1Entry.insert(0, TC1B)
4598  except:
4599  TC1B = CHB_TC1.get()
4600  try:
4601  TC2B = float(chb_TC2Entry.get())
4602  if TC2B < 0:
4603  TC2B = 0
4604  chb_TC2Entry.delete(0, END)
4605  chb_TC2Entry.insert(0, TC2B)
4606  except:
4607  TC2B = CHB_TC2.get()
4608  #
4609  try:
4610  Gain1B = float(chb_A1Entry.get())
4611  except:
4612  Gain1B = CHB_A1.get()
4613  try:
4614  Gain2B = float(chb_A2Entry.get())
4615  except:
4616  Gain2B = CHB_A2.get()
4617  #
4618  if len(VBuffB) > 4:
4619  VBuffB = Digital_RC_High_Pass( VBuffB, TC1B, Gain1B )
4620  VBuffB = Digital_RC_High_Pass( VBuffB, TC2B, Gain2B )
4621  if CHBI_RC_HP.get() == 1:
4622  IBuffB = Digital_RC_High_Pass( IBuffB, TC1B, Gain1B )
4623  #IBuffB = Digital_RC_High_Pass( IBuffB, TC2B, Gain2B )
4624 # Check if need to DeSkew waveform data
4625  if DigDeSkewA.get() > 0:
4626  Shift = int(BCASkewEntry.get())
4627  if Shift != 0:
4628  VBuffA = numpy.roll(VBuffA, Shift)
4629  if DigDeSkewB.get() > 0:
4630  Shift = int(BCBSkewEntry.get())
4631  if Shift != 0:
4632  VBuffB = numpy.roll(VBuffB, Shift)
4633 # check if digital filter box checked
4634  if DigFiltA.get() == 1:
4635  if len(DFiltACoef) > 1:
4636  VBuffA = numpy.convolve(VBuffA, DFiltACoef)
4637  if DigFiltB.get() == 1:
4638  if len(DFiltBCoef) > 1:
4639  VBuffB = numpy.convolve(VBuffB, DFiltBCoef)
4640 # Find trigger sample point if necessary
4641  LShift = 0
4642  if ChopMuxMode.get() > 0 and MuxScreenStatus.get() > 0:
4643  if ChopTrig.get() == 1:
4644  FindTriggerSample(VBuffMA)
4645  if ChopTrig.get() == 2:
4646  FindTriggerSample(VBuffMB)
4647  if ChopTrig.get() == 3:
4648  FindTriggerSample(VBuffMC)
4649  if ChopTrig.get() == 4:
4650  FindTriggerSample(VBuffMD)
4651  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4652  # Average mode 1, add difference / TRACEaverage to array
4653  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0:
4654  LShift = 0 - TRIGGERsample
4655  VBuffMA = numpy.roll(VBuffMA, LShift)
4656  VBuffMB = numpy.roll(VBuffMB, LShift)
4657  VBuffMC = numpy.roll(VBuffMC, LShift)
4658  VBuffMD = numpy.roll(VBuffMD, LShift)
4659  IBuffA = numpy.roll(IBuffA, LShift)
4660  IBuffB = numpy.roll(IBuffB, LShift)
4661  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4662  if ChopTrig.get() == 1:
4663  ReInterploateTrigger(VBuffMA)
4664  if ChopTrig.get() == 2:
4665  ReInterploateTrigger(VBuffMB)
4666  if ChopTrig.get() == 3:
4667  ReInterploateTrigger(VBuffMC)
4668  if ChopTrig.get() == 4:
4669  ReInterploateTrigger(VBuffMD)
4670  else:
4671  if TgInput.get() == 1:
4672  FindTriggerSample(VBuffA)
4673  if TgInput.get() == 2:
4674  FindTriggerSample(IBuffA)
4675  if TgInput.get() == 3:
4676  FindTriggerSample(VBuffB)
4677  if TgInput.get() == 4:
4678  FindTriggerSample(IBuffB)
4679  if TgInput.get() == 5:
4680  FindTriggerSample(VBuffA)
4681  if Is_Triggered == 0: # Trigger event not found for VBuffA so Try VBuffB
4682  FindTriggerSample(VBuffB)
4683  if TgInput.get() == 6:
4684  FindTriggerSample(VBuffA)
4685  TRIGGERsampleAltA = TRIGGERsample
4686  FindTriggerSample(VBuffB)
4687  TRIGGERsampleAltB = TRIGGERsample
4688  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4689  # Average mode 1, add difference / TRACEaverage to array
4690  if TgInput.get() > 0: # if triggering left shift all arrays such that trigger point is at index 0
4691  LShift = 0 - TRIGGERsample
4692  if TgInput.get() == 6:
4693  LShift = 0 - TRIGGERsampleAltA
4694  VBuffA = numpy.roll(VBuffA, LShift)
4695  IBuffA = numpy.roll(IBuffA, LShift)
4696  LShift = 0 - TRIGGERsampleAltB
4697  VBuffB = numpy.roll(VBuffB, LShift)
4698  IBuffB = numpy.roll(IBuffB, LShift)
4699  else:
4700  VBuffA = numpy.roll(VBuffA, LShift)
4701  VBuffB = numpy.roll(VBuffB, LShift)
4702  IBuffA = numpy.roll(IBuffA, LShift)
4703  IBuffB = numpy.roll(IBuffB, LShift)
4704  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4705  try:
4706  if DualMuxMode.get() == 0: # and MuxScreenStatus.get() == 0: # average A voltage data only if not in dual split I/O Mux Mode
4707  VBuffA = VmemoryA + (VBuffA - VmemoryA) / TRACEaverage.get()
4708  IBuffA = ImemoryA + (IBuffA - ImemoryA) / TRACEaverage.get()
4709  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
4710  VBuffB = VmemoryB + (VBuffB - VmemoryB) / TRACEaverage.get()
4711  IBuffB = ImemoryB + (IBuffB - ImemoryB) / TRACEaverage.get()
4712  except:
4713  # buffer size mismatch so reset memory buffers
4714  VmemoryA = VBuffA
4715  if MuxScreenStatus.get() == 0: # average B voltage data only if not in Mux Mode
4716  VmemoryB = VBuffB
4717  ImemoryA = IBuffA
4718  ImemoryB = IBuffB
4719  if TgInput.get() == 1 or TgInput.get() == 5 or TgInput.get() == 6:
4720  ReInterploateTrigger(VBuffA)
4721  if TgInput.get() == 2:
4722  ReInterploateTrigger(IBuffA)
4723  if TgInput.get() == 3 or TgInput.get() == 5 or TgInput.get() == 6:
4724  ReInterploateTrigger(VBuffB)
4725  if TgInput.get() == 4:
4726  ReInterploateTrigger(IBuffB)
4727 # DC value = average of the data record
4728  if CHA_RC_HP.get() == 1 or CHB_RC_HP.get() == 1:
4729  Endsample = hldn+onescreen # average over only one screen's worth of samples
4730  else:
4731  Endsample = SHOWsamples - 10 # average over all samples
4732  if MeasGateStatus.get() == 1:
4733  if (MeasGateRight-MeasGateLeft) > 0:
4734  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
4735  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
4736  if Endsample <= hldn:
4737  Endsample = hldn + 2
4738 # Calculate VA scalar values
4739  DCV1 = numpy.mean(VBuffA[hldn:Endsample])
4740  DCV2 = numpy.mean(VBuffB[hldn:Endsample])
4741  DCI1 = numpy.mean(IBuffA[hldn:Endsample])
4742  DCI2 = numpy.mean(IBuffB[hldn:Endsample])
4743 # find min and max values
4744  MinV1 = numpy.amin(VBuffA[hldn:Endsample])
4745  MaxV1 = numpy.amax(VBuffA[hldn:Endsample])
4746  MinV2 = numpy.amin(VBuffB[hldn:Endsample])
4747  MaxV2 = numpy.amax(VBuffB[hldn:Endsample])
4748  MinI1 = numpy.amin(IBuffA[hldn:Endsample])
4749  MaxI1 = numpy.amax(IBuffA[hldn:Endsample])
4750  MinI2 = numpy.amin(IBuffB[hldn:Endsample])
4751  MaxI2 = numpy.amax(IBuffB[hldn:Endsample])
4752 # RMS value = square root of average of the data record squared
4753  SV1 = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample])))
4754  SI1 = numpy.sqrt(numpy.mean(numpy.square(IBuffA[hldn:Endsample])))
4755  SV2 = numpy.sqrt(numpy.mean(numpy.square(VBuffB[hldn:Endsample])))
4756  SI2 = numpy.sqrt(numpy.mean(numpy.square(IBuffB[hldn:Endsample])))
4757  SVA_B = numpy.sqrt(numpy.mean(numpy.square(VBuffA[hldn:Endsample]-VBuffB[hldn:Endsample])))
4758 # Transfer to mux buffers as necessary
4759  if TgInput.get() > 0 and TRACEmodeTime.get() != 1: # and MuxChan > -1
4760  # if triggering left shift all arrays such that trigger point is at index 0
4761  LShift = 0 - TRIGGERsample
4762  VBuffA = numpy.roll(VBuffA, LShift)
4763  VBuffB = numpy.roll(VBuffB, LShift)
4764  IBuffA = numpy.roll(IBuffA, LShift)
4765  IBuffB = numpy.roll(IBuffB, LShift)
4766  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4767  if ChopMuxMode.get() == 1 and ChopTrig.get() > 0 and TRACEmodeTime.get() != 1:
4768  LShift = 0 - TRIGGERsample
4769  VBuffMA = numpy.roll(VBuffMA, LShift)
4770  VBuffMB = numpy.roll(VBuffMB, LShift)
4771  VBuffMC = numpy.roll(VBuffMC, LShift)
4772  VBuffMD = numpy.roll(VBuffMD, LShift)
4773  IBuffA = numpy.roll(IBuffA, LShift)
4774  IBuffB = numpy.roll(IBuffB, LShift)
4775  TRIGGERsample = hozpos # set trigger sample to index 0 offset by horizontal position
4776  if ChopMuxMode.get() == 1 and TRACEmodeTime.get() == 1: # also if in chop mode cal avaerage
4777  # Average mode 1, add difference / TRACEaverage to array
4778  try:
4779  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
4780  except: # buffer size mismatch so reset memory buffers
4781  VmemoryMuxA = VBuffMA
4782  try:
4783  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
4784  except: # buffer size mismatch so reset memory buffers
4785  VmemoryMuxB = VBuffMB
4786  try:
4787  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
4788  except: # buffer size mismatch so reset memory buffers
4789  VmemoryMuxC = VBuffMC
4790  try:
4791  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
4792  except: # buffer size mismatch so reset memory buffers
4793  VmemoryMuxD = VBuffMD
4794  if MuxChan > -1 and ChopMuxMode.get() == 0: # do this when not in chop mux mode
4795  if Show_CBA.get() == 1 and MuxChan == 0: # Dval0[0] == 0 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
4796  DCVMuxA = DCV2
4797  MinVMuxA = MinV2
4798  MaxVMuxA = MaxV2
4799  MidVMuxA = (MaxV2+MinV2)/2.0
4800  PPVMuxA = MaxV2-MinV2
4801  SVMuxA = SV2
4802  VBuffMA = VBuffB
4803  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4804  # Average mode 1, add difference / TRACEaverage to array
4805  try:
4806  VBuffMA = VmemoryMuxA + (VBuffMA - VmemoryMuxA) / TRACEaverage.get()
4807  except:
4808  # buffer size mismatch so reset memory buffers
4809  VmemoryMuxA = VBuffMA
4810  if Show_CBB.get() == 1 and MuxChan == 1: # Dval0[0] == 1 and Dval1[0] == 0 and ChopMuxMode.get() == 0:
4811  DCVMuxB = DCV2
4812  MinVMuxB = MinV2
4813  MaxVMuxB = MaxV2
4814  MidVMuxB = (MaxV2+MinV2)/2.0
4815  PPVMuxB = MaxV2-MinV2
4816  SVMuxB = SV2
4817  VBuffMB = VBuffB
4818  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4819  # Average mode 1, add difference / TRACEaverage to array
4820  try:
4821  VBuffMB = VmemoryMuxB + (VBuffMB - VmemoryMuxB) / TRACEaverage.get()
4822  except:
4823  # buffer size mismatch so reset memory buffers
4824  VmemoryMuxB = VBuffMB
4825  if Show_CBC.get() == 1 and MuxChan == 2: #and Dval0[0] == 0 and Dval1[0] == 1
4826  if DualMuxMode.get() == 1 :
4827  DCVMuxC = DCV1
4828  MinVMuxC = MinV1
4829  MaxVMuxC = MaxV1
4830  MidVMuxC = (MaxV1+MinV1)/2.0
4831  PPVMuxC = MaxV1-MinV1
4832  SVMuxC = SV1
4833  VBuffMC = VBuffA
4834  else:
4835  DCVMuxC = DCV2
4836  MinVMuxC = MinV2
4837  MaxVMuxC = MaxV2
4838  MidVMuxC = (MaxV2+MinV2)/2.0
4839  PPVMuxC = MaxV2-MinV2
4840  SVMuxC = SV2
4841  VBuffMC = VBuffB
4842  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4843  # Average mode 1, add difference / TRACEaverage to array
4844  try:
4845  VBuffMC = VmemoryMuxC + (VBuffMC - VmemoryMuxC) / TRACEaverage.get()
4846  except:
4847  # buffer size mismatch so reset memory buffers
4848  VmemoryMuxC = VBuffMC
4849  if Show_CBD.get() == 1 and MuxChan == 3: #and Dval0[0] == 1 and Dval1[0] == 1
4850  if DualMuxMode.get() == 1 :
4851  DCVMuxD = DCV1
4852  MinVMuxD = MinV1
4853  MaxVMuxD = MaxV1
4854  MidVMuxD = (MaxV1+MinV1)/2.0
4855  PPVMuxD = MaxV1-MinV1
4856  SVMuxD = SV1
4857  VBuffMD = VBuffA
4858  else:
4859  DCVMuxD = DCV2
4860  MinVMuxD = MinV2
4861  MaxVMuxD = MaxV2
4862  MidVMuxD = (MaxV2+MinV2)/2.0
4863  PPVMuxD = MaxV2-MinV2
4864  SVMuxD = SV2
4865  VBuffMD = VBuffB
4866  if TRACEmodeTime.get() == 1 and TRACEresetTime == False:
4867  # Average mode 1, add difference / TRACEaverage to array
4868  try:
4869  VBuffMD = VmemoryMuxD + (VBuffMD - VmemoryMuxD) / TRACEaverage.get()
4870  except:
4871  # buffer size mismatch so reset memory buffers
4872  VmemoryMuxD = VBuffMD
4873  # update screens
4874  if TimeDisp.get() > 0:
4875  # Check if in non functional state of 2X samplerate and 3 or more traces amd not enabled AWGSync
4876  NumTraces = ShowC1_V.get() + ShowC1_I.get() + ShowC2_V.get() + ShowC2_I.get()
4877  if NumTraces > 2 and AWGSync.get() == 0 and Two_X_Sample.get() == 1:
4878  showwarning("WARNING","You need to Select only 2 Traces or Enable AWG Sync Mode!")
4879  BStop()
4880  # return
4881  UpdateTimeAll() # Update Data, trace and time screen
4882  if XYDisp.get() > 0 and XYScreenStatus.get() > 0:
4883  UpdateXYAll() # Update Data, trace and XY screen
4884  if SingleShot.get() > 0 and Is_Triggered == 1: # Singel Shot trigger is on
4885  BStop() #
4886  SingleShot.set(0)
4887  if ManualTrigger.get() == 1: # Manual trigger is on
4888  BStop() #
4889  if MeasureStatus.get() > 0:
4891 #
4892 # Function to calculate relative phase angle between two sine waves of the same frequency
4893 # Removes any DC content
4895  global DCV1, DCV2, VBuffA, VBuffB
4896 
4897  sum1 = 0.0
4898  sum2 = 0.0
4899  sum12 = 0.0
4900  i = 0
4901  n = len(VBuffA)
4902  while i < n:
4903  sum1 += (VBuffA[i]-DCV1)*(VBuffA[i]-DCV1)
4904  sum2 += (VBuffB[i]-DCV2)*(VBuffB[i]-DCV2)
4905  sum12 += (VBuffA[i]-DCV1)*(VBuffB[i]-DCV2)
4906  i += 1
4907  return math.acos(sum12/math.sqrt(sum1*sum2))*180.0/numpy.pi
4908 #
4909 # High Pass y[n] = alpha * (y[n-1] + x[n] - x[n-1])
4910 # Low Pass y[n] = y[n-1] + (alpha * ((x[n] - x[n-1]))
4911 # All Pass y[n] = alpha * y[n-1] - alpha * (x[n] + x[n-1])
4912 # All Pass y[n] = alpha * (y[n-1] - x[n] - x[n-1])
4913 
4914 
4916 def Digital_RC_High_Pass( InBuff, TC1, Gain ):
4917  global SAMPLErate, Two_X_Sample
4918 
4919  OutBuff = []
4920  n = len(InBuff)
4921  if Two_X_Sample.get() == 0:
4922  Delta = 1.0/SAMPLErate
4923  else: # adjust for sligh difference in 2X sample mode?
4924  Delta = 0.88/SAMPLErate
4925  TC = TC1 * 1.0E-6
4926  Alpha = TC / (TC + Delta)
4927  OutBuff.append(0.0) # initialize first output sample
4928  i = 1
4929  while i < n:
4930  OutBuff.append( Alpha * (OutBuff[i-1] + InBuff[i] - InBuff[i-1]) )
4931  i += 1
4932  OutBuff = numpy.array(OutBuff)
4933  OutBuff = InBuff + (OutBuff * Gain)
4934  return OutBuff
4935 
4937 def Digital_RC_Low_Pass( InBuff, TC1, Gain ): # TC1 is in micro seconds
4938  global SAMPLErate
4939 
4940  OutBuff = []
4941  n = len(InBuff)
4942  Delta = 1.0/SAMPLErate
4943  TC = TC1 * 1.0E-6
4944  Alpha = Delta / (TC + Delta)
4945  i = 1
4946  OutBuff.append(Alpha*InBuff[0])
4947  while i < n:
4948  OutBuff.append( OutBuff[i-1] + (Alpha * (InBuff[i] - InBuff[i-1])) )
4949  i += 1
4950  OutBuff = numpy.array(OutBuff)
4951  OutBuff = (OutBuff * Gain)
4952  return OutBuff
4953 
4957 def shift_buffer(arr, num, fill_value=numpy.nan):
4958  result = numpy.empty_like(arr)
4959  if num > 0:
4960  result[:num] = fill_value
4961  result[num:] = arr[:-num]
4962  elif num < 0:
4963  result[num:] = fill_value
4964  result[:num] = arr[-num:]
4965  else:
4966  result[:] = arr
4967  return result
4968 
4969 
4972  global ADsignal1, FFTBuffA, FFTBuffB, SMPfft
4973  global AWGSync, AWGAMode, AWGBMode, AWGAShape, AWGAIOMode, AWGBIOMode
4974  global AWGAFreqvalue, AWGBFreqvalue, FStepSync, FSweepSync
4975  global NSteps, LoopNum, FSweepMode, FStep, FBins
4976  global StartFreqEntry, StopFreqEntry, HoldOffentry
4977  global session, CHA, CHB, devx, MaxSamples, discontloop
4978  global RUNstatus, SingleShotSA, FSweepCont, Two_X_Sample, ADC_Mux_Mode
4979  global AWGSAMPLErate, IAScreenStatus, SpectrumScreenStatus, BodeScreenStatus
4980  global NiCScreenStatus, NiCDisp, NqPScreenStatus, NqPDisp
4981  global OverRangeFlagA, OverRangeFlagB, BodeDisp, FreqDisp, IADisp
4982  global DCA, DCB, InOffA, InGainA, InOffB, InGainB
4983  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
4984  global DigFiltA, DFiltACoef, DigFiltB, DFiltBCoef
4985  global BDSweepFile, FileSweepFreq, FileSweepAmpl
4986  global PIO_0, PIO_1, PIO_2, PIO_3
4987  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
4988  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
4989  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
4990  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
4991  global Reset_Freq, AWGAFreqEntry, AWGBFreqEntry, MinigenFout, IASource, IA_Ext_Conf
4992 
4993  HalfSAMPLErate = SAMPLErate/2
4994  # Do input divider Calibration CH1VGain, CH2VGain, CH1VOffset, CH2VOffset
4995  try:
4996  InOffA = float(eval(CHAVOffsetEntry.get()))
4997  except:
4998  CHAVOffsetEntry.delete(0,END)
4999  CHAVOffsetEntry.insert(0, InOffA)
5000  try:
5001  InGainA = float(eval(CHAVGainEntry.get()))
5002  except:
5003  CHAVGainEntry.delete(0,END)
5004  CHAVGainEntry.insert(0, InGainA)
5005  try:
5006  InOffB = float(eval(CHBVOffsetEntry.get()))
5007  except:
5008  CHBVOffsetEntry.delete(0,END)
5009  CHBVOffsetEntry.insert(0, InOffB)
5010  try:
5011  InGainB = float(eval(CHBVGainEntry.get()))
5012  except:
5013  CHBVGainEntry.delete(0,END)
5014  CHBVGainEntry.insert(0, InGainB)
5015  try:
5016  HoldOff = float(eval(HoldOffentry.get()))
5017  if HoldOff < 0:
5018  HoldOff = 0
5019  HoldOffentry.delete(0,END)
5020  HoldOffentry.insert(0, HoldOff)
5021  except:
5022  HoldOffentry.delete(0,END)
5023  HoldOffentry.insert(0, HoldOff)
5024  #
5025  INITIALIZEstart()
5026  # Starting acquisition This is a HACK to get around non-continous AWG mode!
5027  # restart AWGs if indicated
5028  if BodeDisp.get() == 0: # make new noise waveforms each sweep
5029  if AWGAShape.get() == 7 and AWGAMode.get() == 0:
5030  AWGAMakeUUNoise()
5031  elif AWGAShape.get() == 8 and AWGAMode.get() == 0:
5032  AWGAMakeUGNoise()
5033  elif AWGBShape.get() == 7 and AWGBMode.get() == 0:
5034  AWGBMakeUUNoise()
5035  elif AWGBShape.get() == 8 and AWGBMode.get() == 0:
5036  AWGBMakeUGNoise()
5037  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Run Sweep Gen only if sleceted and Bode display is active
5038  if BDSweepFile.get() == 0:
5039  if LoopNum.get() <= len(FStep):
5040  FregPoint = FBins[int(FStep[LoopNum.get()-1])] # look up next frequency from list of bins
5041  else:
5042  FregPoint = FBins[FStep[0]]
5043  else:
5044  if LoopNum.get() <= len(FileSweepFreq): #
5045  FreqIndex = int((FileSweepFreq[LoopNum.get()-1]*16384)/HalfSAMPLErate)
5046  FregPoint = FBins[FreqIndex] # look up next frequency from list of bins
5047  VRMSAmpl = 10**(FileSweepAmpl[LoopNum.get()-1]/20) # convert to V RMS 0 dBV = 1V RMS
5048  else:
5049  FregPoint = FBins[FileSweepFreq[0]]
5050  VRMSAmpl = 10**(FileSweepAmpl[0]/20) # convert to V RMS 0 dBV = 1V RMS
5051  VMax = 2.5 + (1.414*VRMSAmpl) # calculate positive peak assuming sine wave
5052  VMin = 2.5 - (1.414*VRMSAmpl) # calculate negative peak assuming sine wave
5053  if FSweepMode.get() == 1: # set new CH-A amplitude
5054  AWGAAmplEntry.delete(0,END)
5055  AWGAAmplEntry.insert(4, VMin)
5056  AWGAOffsetEntry.delete(0,END)
5057  AWGAOffsetEntry.insert(4, VMax)
5058  if FSweepMode.get() == 2: # set new CH-B amplitude
5059  AWGBAmplEntry.delete(0,END)
5060  AWGBAmplEntry.insert(4, VMin)
5061  AWGBOffsetEntry.delete(0,END)
5062  AWGBOffsetEntry.insert(4, VMax)
5063  if FSweepMode.get() == 1: # set new CH-A frequency
5064  AWGAFreqEntry.delete(0,END)
5065  AWGAFreqEntry.insert(4, FregPoint)
5067  if FSweepMode.get() == 2: # set new CH-B frequency
5068  AWGBFreqEntry.delete(0,END)
5069  AWGBFreqEntry.insert(4, FregPoint)
5071  if FSweepMode.get() == 3: # set new MiniGen frequency
5072  MinigenFout.delete(0,END)
5073  MinigenFout.insert(4, FregPoint)
5074  BSendMG()
5075  if AWGSync.get() > 0:
5076  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5077  if Two_X_Sample.get() == 1:
5078  AWGBIOMode.set(1)
5079  AWGBMode.set(0)
5080  else:
5081  AWGBMode.set(2)
5082  # BAWGEnab()
5083 #
5084  hldn = int(HoldOff * 100 )
5085  if hldn > MaxSamples-SMPfft:
5086  hldn = MaxSamples-SMPfft
5087  HoldOffentry.delete(0,END)
5088  HoldOffentry.insert(0, hldn/100)
5089  if hldn < 128:
5090  hldn = 128
5091  SHOWsamples = SMPfft + hldn # get holf off extra samples
5092  if BodeDisp.get() > 0: # check if doing Bode Plot
5093  if FStepSync.get() == 1: # output low - high - low pulse on PIO-0
5094  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5095  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5096  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5097  if FStepSync.get() == 2: # output high - low - high pulse on PIO-0
5098  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5099  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100)
5100  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100)
5101  if LoopNum.get() == 1 and FSweepSync.get() == 1: # output low - high - low pulse on PIO-1
5102  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5103  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5104  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5105  if LoopNum.get() == 1 and FSweepSync.get() == 2: # output high - low - high pulse on PIO-1
5106  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5107  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100)
5108  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100)
5109  if AWGScreenStatus.get() == 1: # don't try to start AWG is AWG screen is closed
5110  if IAScreenStatus.get() > 0 and IASource.get() == 0:
5111  if Two_X_Sample.get() == 1:
5112  AWGBIOMode.set(1)
5113  AWGBMode.set(0)
5114  else:
5115  AWGBMode.set(2)
5116  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
5117  if discontloop > 0:
5118  session.flush()
5119  else:
5120  discontloop = 1
5121  BAWGEnab()
5122  try:
5123  ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5124  except:
5125  donothing()
5126  # waite to finish then return to open termination
5127  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5128  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5129  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5130  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5131  else: # running in continuous mode
5132  ADsignal1 = devx.read(SHOWsamples, -1, True) # get samples for both channel A and B
5133  #
5134  else:
5135  if session.continuous:
5136  ADsignal1 = devx.read(SHOWsamples, -1, True)
5137  # ADsignal1 = devx.get_samples(SHOWsamples) # get samples for both channel A and B
5138  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
5139  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
5140  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
5141  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
5142  FFTBuffA = [] # Clear the FFTBuff array for trace A
5143  FFTBuffB = [] # Clear the FFTBuff array for trace B
5144  OverRangeFlagA = OverRangeFlagB = 0 # Clear over range flags
5145  index = hldn # skip first hldn samples
5146  if SHOWsamples != len(ADsignal1):
5147  SHOWsamples = len(ADsignal1)
5148  while index < SHOWsamples:
5149  if Two_X_Sample.get() == 1:
5150  if ADC_Mux_Mode.get() == 0: # VA and VB
5151  FFTBuffA.append(ADsignal1[index][0][0])
5152  FFTBuffA.append(ADsignal1[index][1][1])
5153  FFTBuffB.append(ADsignal1[index][0][1])
5154  FFTBuffB.append(ADsignal1[index][1][0])
5155  else:
5156  VAdata = ADsignal1[index][0][0]
5157  FFTBuffA.append(VAdata)
5158  VBdata = ADsignal1[index][1][0]
5159  FFTBuffB.append(VBdata)
5160  if VAdata > 5.0 or VAdata < 0.0:
5161  OverRangeFlagA = 1
5162 
5163  if VBdata > 5.0 or VBdata < 0.0:
5164  OverRangeFlagB = 1
5165  index = index + 1
5166 
5167  FFTBuffA = numpy.array(FFTBuffA)
5168  FFTBuffB = numpy.array(FFTBuffB)
5169  FFTBuffA = (FFTBuffA - InOffA) * InGainA
5170  FFTBuffB = (FFTBuffB - InOffB) * InGainB
5171  DCA = numpy.average(FFTBuffA)
5172  DCB = numpy.average(FFTBuffB)
5173  if CutDC.get() == 1:
5174  FFTBuffA = FFTBuffA - DCA
5175  FFTBuffB = FFTBuffB - DCB
5176 # Check if Input channel RC high pass compensation checked cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
5177  if CHA_RC_HP.get() == 1:
5178  try:
5179  TC1A = float(cha_TC1Entry.get())
5180  if TC1A < 0:
5181  TC1A = 0
5182  cha_TC1Entry.delete(0,END)
5183  cha_TC1Entry.insert(0, TC1A)
5184  except:
5185  TC1A = CHA_TC1.get()
5186  try:
5187  TC2A = float(cha_TC2Entry.get())
5188  if TC2A < 0:
5189  TC2A = 0
5190  cha_TC2Entry.delete(0,END)
5191  cha_TC2Entry.insert(0, TC2A)
5192  except:
5193  TC2A = CHA_TC2.get()
5194  #
5195  try:
5196  Gain1A = float(cha_A1Entry.get())
5197  except:
5198  Gain1A = CHA_A1.get()
5199  try:
5200  Gain2A = float(cha_A2Entry.get())
5201  except:
5202  Gain2A = CHA_A2.get()
5203  #
5204  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC1A, Gain1A )
5205  FFTBuffA = Digital_RC_High_Pass( FFTBuffA, TC2A, Gain2A )
5206  if CHB_RC_HP.get() == 1:
5207  try:
5208  TC1B = float(chb_TC1Entry.get())
5209  if TC1B < 0:
5210  TC1B = 0
5211  chb_TC1Entry.delete(0, END)
5212  chb_TC1Entry.insert(0, TC1B)
5213  except:
5214  TC1B = CHB_TC1.get()
5215  try:
5216  TC2B = float(chb_TC2Entry.get())
5217  if TC2B < 0:
5218  TC2B = 0
5219  chb_TC2Entry.delete(0, END)
5220  chb_TC2Entry.insert(0, TC2B)
5221  except:
5222  TC2B = CHB_TC2.get()
5223  #
5224  try:
5225  Gain1B = float(chb_A1Entry.get())
5226  except:
5227  Gain1B = CHB_A1.get()
5228  try:
5229  Gain2B = float(chb_A2Entry.get())
5230  except:
5231  Gain2B = CHB_A2.get()
5232  #
5233  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC1B, Gain1B )
5234  FFTBuffB = Digital_RC_High_Pass( FFTBuffB, TC2B, Gain2B )
5235 # check if digital filter box checked
5236  if DigFiltA.get() == 1:
5237  FFTBuffA = numpy.convolve(FFTBuffA, DFiltACoef)
5238  if DigFiltB.get() == 1:
5239  FFTBuffB = numpy.convolve(FFTBuffB, DFiltBCoef)
5240  DoFFT()
5241  if SpectrumScreenStatus.get() > 0 and FreqDisp.get() > 0:
5242  UpdateFreqAll() # Update spectrum Data, trace and screen
5243  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
5244  UpdateIAAll()
5245  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
5246  UpdateBodeAll()
5247  if NqPScreenStatus.get() > 0 and NqPDisp.get() > 0:
5248  UpdateNqPAll()
5249  if NiCScreenStatus.get() > 0 and NiCDisp.get() > 0:
5250  UpdateNiCAll()
5251  if SingleShotSA.get() == 1: # Single shot sweep is on
5252  RUNstatus.set(0)
5253 #
5254  if FSweepMode.get() > 0 and BodeDisp.get() > 0: # Increment loop counter only if sleceted and Bode display is active
5255  LoopNum.set(LoopNum.get() + 1)
5256  if LoopNum.get() > NSteps.get():
5257  if FSweepMode.get() == 1:
5258  AWGAFreqEntry.delete(0,"end")
5259  AWGAFreqEntry.insert(0, Reset_Freq)
5260  if FSweepMode.get() == 2:
5261  AWGBFreqEntry.delete(0,"end")
5262  AWGBFreqEntry.insert(0, Reset_Freq)
5263 #
5264  LoopNum.set(1)
5265  if FSweepCont.get() == 0:
5266  RUNstatus.set(0)
5267 #
5268 
5270  global VBuffA, VBuffB, IBuffA, IBuffB, HBuffA, HBuffB
5271  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
5272  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Xsignal
5273  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
5274  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
5275  global VABase, VATop, VBBase, VBTop
5276 
5277  if ShowC1_V.get() == 1 or Xsignal.get() == 6:
5278  CHAGridMax = (5 * CH1pdvRange ) + CHAOffset # Calculate CHA Grid Min and Max
5279  CHAGridMin = (-5 * CH1pdvRange ) + CHAOffset
5280  VAMid = (MinV1 + MaxV1)/2 # Find CHA mid value
5281  HBuffA = numpy.histogram(VBuffA, bins=5000, range=[CHAGridMin, CHAGridMax] )
5282  LowerPeak = 0
5283  UpperPeak = 0
5284  b = 0
5285  while (b < 4999):
5286  if HBuffA[0][b] > HBuffA[0][LowerPeak] and HBuffA[1][b] < VAMid:
5287  LowerPeak = b
5288  VABase = HBuffA[1][b]
5289  if HBuffA[0][b] > HBuffA[0][UpperPeak] and HBuffA[1][b] > VAMid:
5290  UpperPeak = b
5291  VATop = HBuffA[1][b]
5292  b = b + 1
5293  if ShowC2_V.get() == 1 or Xsignal.get() == 7:
5294  CHBGridMax = (5 * CH2pdvRange ) + CHBOffset # Calculate CHB Grid Min and Max
5295  CHBGridMin = (-5 * CH2pdvRange ) + CHBOffset
5296  VBMid = (MinV2 + MaxV2)/2 # Find CHB mid value
5297  HBuffB = numpy.histogram(VBuffB, bins=5000, range=[CHBGridMin, CHBGridMax] )
5298  LowerPeak = 0
5299  UpperPeak = 0
5300  b = 0
5301  while (b < 4999):
5302  if HBuffB[0][b] > HBuffB[0][LowerPeak] and HBuffB[1][b] < VBMid:
5303  LowerPeak = b
5304  VBBase = HBuffB[1][b]
5305  if HBuffB[0][b] > HBuffB[0][UpperPeak] and HBuffB[1][b] > VBMid:
5306  UpperPeak = b
5307  VBTop = HBuffB[1][b]
5308  b = b + 1
5309 
5311  global HistAsPercent
5312 
5313  if askyesno("Plot as Percent", "Plot Histogram as Percent?", parent=xywindow):
5314  HistAsPercent = 1
5315  else:
5316  HistAsPercent = 0
5317 
5318 def FindRisingEdge(Trace1, Trace2):
5319  global MinV1, MaxV1, MinV2, MaxV2, HoldOff, TRIGGERsample, TgInput, LShift
5320  global ETSrecord, DISsamples
5321  global SHOWsamples, SAMPLErate, CHAperiod, CHAfreq, CHBperiod, CHBfreq
5322  global CHAHW, CHALW, CHADCy, CHBHW, CHBLW, CHBDCy, ShowC1_V, ShowC2_V
5323  global CHABphase, CHBADelayR1, CHBADelayR2, CHBADelayF
5324 
5325  anr1 = bnr1 = 0
5326  anf1 = bnf1 = 1
5327  anr2 = bnr2 = 2
5328  hldn = int(HoldOff * SAMPLErate/1000)
5329  # print(DISsamples, len(Trace1))
5330  if TgInput.get() > 0: # if triggering right shift arrays to undo trigger left shift
5331  Trace1 = numpy.roll(Trace1, -LShift)
5332  Trace2 = numpy.roll(Trace2, -LShift)
5333  else:
5334  Trace1 = numpy.roll(Trace1, -hldn)
5335  Trace2 = numpy.roll(Trace2, -hldn)
5336  try:
5337  MidV1 = (numpy.amax(Trace1)+numpy.amin(Trace1))/2.0
5338  MidV2 = (numpy.amax(Trace2)+numpy.amin(Trace2))/2.0
5339  except:
5340  MidV1 = (MinV1+MaxV1)/2
5341  MidV2 = (MinV2+MaxV2)/2
5342 # search Trace 1
5343 
5350  Arising = [i for (i, val) in enumerate(Trace1) if val >= MidV1 and Trace1[i-1] < MidV1]
5351  Afalling = [i for (i, val) in enumerate(Trace1) if val <= MidV1 and Trace1[i-1] > MidV1]
5352  AIrising = [i - (Trace1[i] - MidV1)/(Trace1[i] - Trace1[i-1]) for i in Arising]
5353  AIfalling = [i - (MidV1 - Trace1[i])/(Trace1[i-1] - Trace1[i]) for i in Afalling]
5354 
5355  CHAfreq = SAMPLErate / numpy.mean(numpy.diff(AIrising))
5356  CHAperiod = (numpy.mean(numpy.diff(AIrising)) * 1000.0) / SAMPLErate # time in mSec
5357 # Catch zero length array?
5358  try:
5359  Dummy_read = Arising[0]
5360  except:
5361  return
5362  if len(Arising) > 0 or len(Afalling) > 0:
5363  if Arising[0] > 0:
5364  try:
5365  anr1 = AIrising[0]
5366  except:
5367  anr1 = 0
5368  try:
5369  anr2 = AIrising[1]
5370  except:
5371  anr2 = SHOWsamples
5372  try:
5373  if AIfalling[0] < AIrising[0]:
5374  anf1 = AIfalling[1]
5375  else:
5376  anf1 = AIfalling[0]
5377  except:
5378  anf1 = 1
5379  else:
5380  try:
5381  anr1 = AIrising[1]
5382  except:
5383  anr1 = 0
5384  try:
5385  anr2 = AIrising[2]
5386  except:
5387  anr2 = SHOWsamples
5388  try:
5389  if AIfalling[1] < AIrising[1]:
5390  anf1 = AIfalling[2]
5391  else:
5392  anf1 = AIfalling[1]
5393  except:
5394  anf1 = 1
5395 # search Trace 2
5396 
5403  Brising = [i for (i, val) in enumerate(Trace2) if val >= MidV2 and Trace2[i-1] < MidV2]
5404  Bfalling = [i for (i, val) in enumerate(Trace2) if val <= MidV2 and Trace2[i-1] > MidV2]
5405  BIrising = [i - (Trace2[i] - MidV2)/(Trace2[i] - Trace2[i-1]) for i in Brising]
5406  BIfalling = [i - (MidV2 - Trace2[i])/(Trace2[i-1] - Trace2[i]) for i in Bfalling]
5407 
5408  CHBfreq = SAMPLErate / numpy.mean(numpy.diff(BIrising))
5409  CHBperiod = (numpy.mean(numpy.diff(BIrising)) * 1000.0) / SAMPLErate # time in mSec
5410 # Catch zero length array?
5411  try:
5412  Dummy_read = Brising[0]
5413  except:
5414  return
5415  if len(Brising) > 0 or len(Bfalling) > 0:
5416  if Brising[0] > 0:
5417  try:
5418  bnr1 = BIrising[0]
5419  except:
5420  bnr1 = 0
5421  try:
5422  bnr2 = BIrising[1]
5423  except:
5424  bnr2 = SHOWsamples
5425  try:
5426  if BIfalling[0] < BIrising[0]:
5427  bnf1 = BIfalling[1]
5428  else:
5429  bnf1 = BIfalling[0]
5430  except:
5431  bnf1 = 1
5432  else:
5433  try:
5434  bnr1 = BIrising[1]
5435  except:
5436  bnr1 = 0
5437  try:
5438  bnr2 = BIrising[2]
5439  except:
5440  bnr2 = SHOWsamples
5441  try:
5442  if BIfalling[1] < BIrising[1]:
5443  bnf1 = BIfalling[2]
5444  else:
5445  bnf1 = BIfalling[1]
5446  except:
5447  bnf1 = 1
5448  #
5449  CHAHW = float(((anf1 - anr1) * 1000.0) / SAMPLErate)
5450  CHALW = float(((anr2 - anf1) * 1000.0) / SAMPLErate)
5451  CHADCy = float(anf1 - anr1) / float(anr2 - anr1) * 100.0 # in percent
5452  CHBHW = float(((bnf1 - bnr1) * 1000.0) / SAMPLErate)
5453  CHBLW = float(((bnr2 - bnf1) * 1000.0) / SAMPLErate)
5454  CHBDCy = float(bnf1 - bnr1) / float(bnr2 - bnr1) * 100.0 # in percent
5455 #
5456  if bnr1 > anr1:
5457  CHBADelayR1 = float((bnr1 - anr1) * 1000.0 / SAMPLErate)
5458  else:
5459  CHBADelayR1 = float((bnr2 - anr1) * 1000.0 / SAMPLErate)
5460  CHBADelayR2 = float((bnr2 - anr2) * 1000.0 / SAMPLErate)
5461  CHBADelayF = float((bnf1 - anf1) * 1000.0 / SAMPLErate)
5462  try:
5463  CHABphase = 360.0*(float((bnr1 - anr1) * 1000.0 / SAMPLErate))/CHAperiod
5464  except:
5465  CHABphase = 0.0
5466  if CHABphase < 0.0:
5467  CHABphase = CHABphase + 360.0
5468 
5470  global DX, TRIGGERsample, TRIGGERlevel
5471 
5472  DX = 0
5473  n = TRIGGERsample
5474  DY = TrgBuff[int(n)] - TrgBuff[int(n+1)]
5475  if DY != 0.0:
5476  DX = (TRIGGERlevel - TrgBuff[int(n+1)])/DY # calculate interpolated trigger point
5477  else:
5478  DX = 0
5479 
5480 def FindTriggerSample(TrgBuff): # find trigger time sample point of passed waveform array
5481  global AutoLevel, TgInput, TRIGGERlevel, TRIGGERentry, DX, SAMPLErate, Is_Triggered
5482  global HoldOffentry, HozPossentry, TRIGGERsample, TRACEsize, HozPoss, hozpos
5483  global Trigger_LPF_length, LPFTrigger
5484 
5485  # Set the TRACEsize variable
5486  TRACEsize = SHOWsamples # Set the trace length
5487  DX = 0
5488  Is_Triggered = 0
5489  if LPFTrigger.get() > 0:
5490  TFiltCoef = [] # empty coef array
5491  for n in range(Trigger_LPF_length.get()):
5492  TFiltCoef.append(float(1.0/Trigger_LPF_length.get()))
5493  TFiltCoef = numpy.array(TFiltCoef)
5494  TrgBuff = numpy.convolve(TrgBuff, TFiltCoef)
5495 
5496  if len(TrgBuff) == 0:
5497  return
5498  try:
5499  TrgMin = numpy.amin(TrgBuff)
5500  except:
5501  TrgMin = 0.0
5502  try:
5503  TrgMax = numpy.amax(TrgBuff)
5504  except:
5505  TrgMax = 0.0
5506 # Find trigger sample
5507  try:
5508  if AutoLevel.get() == 1:
5509  TRIGGERlevel = (TrgMin + TrgMax)/2
5510  TRIGGERentry.delete(0,"end")
5511  TRIGGERentry.insert(0, ' {0:.4f} '.format(TRIGGERlevel))
5512  else:
5513  TRIGGERlevel = eval(TRIGGERentry.get())
5514  except:
5515  TRIGGERentry.delete(0,END)
5516  TRIGGERentry.insert(0, TRIGGERlevel)
5517 # Start from first sample after HoldOff
5518  try:
5519  HoldOff = float(eval(HoldOffentry.get()))
5520  if HoldOff < 0:
5521  HoldOff = 0
5522  HoldOffentry.delete(0,END)
5523  HoldOffentry.insert(0, HoldOff)
5524  except:
5525  HoldOffentry.delete(0,END)
5526  HoldOffentry.insert(0, HoldOff)
5527 # slide trace left right by HozPoss
5528  try:
5529  HozPoss = float(eval(HozPossentry.get()))
5530  except:
5531  HozPossentry.delete(0,END)
5532  HozPossentry.insert(0, HozPoss)
5533 
5534  hldn = int(HoldOff * SAMPLErate/1000)
5535  hozpos = int(HozPoss * SAMPLErate/1000)
5536  if hozpos >= 0:
5537  TRIGGERsample = hldn
5538  else:
5539  TRIGGERsample = abs(hozpos)
5540 #
5541  Nmax = int(TRACEsize / 1.5) # first 2/3 of data set
5542  DX = 0
5543  n = TRIGGERsample
5544  TRIGGERlevel2 = 0.99 * TRIGGERlevel # Hysteresis to avoid triggering on noise
5545  if TRIGGERlevel2 < TrgMin:
5546  TRIGGERlevel2 = TrgMin
5547  if TRIGGERlevel2 > TrgMax:
5548  TRIGGERlevel2 = TrgMax
5549  ChInput = TrgBuff[int(n)]
5550  Prev = ChInput
5551  while ( ChInput >= TRIGGERlevel2) and n < Nmax:
5552  n = n + 1
5553  ChInput = TrgBuff[int(n)]
5554  while (ChInput <= TRIGGERlevel) and n < Nmax:
5555  Prev = ChInput
5556  n = n + 1
5557  ChInput = TrgBuff[int(n)]
5558  DY = ChInput - Prev
5559  if DY != 0.0:
5560  DX = (TRIGGERlevel - Prev)/DY # calculate interpolated trigger point
5561  else:
5562  DX = 0
5563  if TgEdge.get() == 1:
5564  TRIGGERlevel2 = 1.01 * TRIGGERlevel
5565  if TRIGGERlevel2 < TrgMin:
5566  TRIGGERlevel2 = TrgMin
5567  if TRIGGERlevel2 > TrgMax:
5568  TRIGGERlevel2 = TrgMax
5569  ChInput = TrgBuff[int(n)]
5570  Prev = ChInput
5571  while (ChInput <= TRIGGERlevel2) and n < Nmax:
5572  n = n + 1
5573  ChInput = TrgBuff[int(n)]
5574  while (ChInput >= TRIGGERlevel) and n < Nmax:
5575  Prev = ChInput
5576  n = n + 1
5577  ChInput = TrgBuff[int(n)]
5578  DY = Prev - ChInput
5579  try:
5580  DX = (Prev - TRIGGERlevel)/DY # calculate interpolated trigger point
5581  except:
5582  DX = 0
5583 
5584 # check to insure trigger point is in bounds
5585  if n < Nmax:
5586  TRIGGERsample = n - 1
5587  Is_Triggered = 1
5588  elif n > Nmax: # Didn't find edge in first 2/3 of data set
5589  TRIGGERsample = 1 + hldn # reset to begining
5590  Is_Triggered = 0
5591  if DX > 1:
5592  DX = 1 # never more than 100% of a sample period
5593  elif DX < 0:
5594  DX = 0 # never less than 0% of a sample period
5595  if math.isnan(DX):
5596  DX = 0
5597  TRIGGERsample = TRIGGERsample + hozpos
5598 
5600  global win2, DigScreenStatus
5601 
5602  DigScreenStatus.set(0)
5603  win2.destroy()
5604 #
5605 def sel(): # change Digital I/O and update screen color readback
5606  global devx, DevID
5607  global D0, D1, D2, D3, D4, D5, D6, D7
5608  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
5609  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
5610  # sending 0x50 = set to 0, 0x51 = set to 1
5611  if D0.get() > 0:
5612  devx.ctrl_transfer( 0x40, D0.get(), PIO_0, 0, 0, 0, 100) # set PIO 0
5613  if D0.get() == 0x50:
5614  digin0.configure(text="Low", background="#00ff00")
5615  else:
5616  digin0.configure(text="Hi", background="#ff0000")
5617  else:
5618  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100)
5619  if Dval[0] == 0:
5620  digin0.configure(text="Low", background="#00ff00")
5621  else:
5622  digin0.configure(text="Hi", background="#ff0000")
5623  if D1.get() > 0:
5624  devx.ctrl_transfer( 0x40, D1.get(), PIO_1, 0, 0, 0, 100) # set PIO 1
5625  if D1.get() == 0x50:
5626  digin1.configure(text="Low", background="#00ff00")
5627  else:
5628  digin1.configure(text="Hi", background="#ff0000")
5629  else:
5630  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100)
5631  if Dval[0] == 0:
5632  digin1.configure(text="Low", background="#00ff00")
5633  else:
5634  digin1.configure(text="Hi", background="#ff0000")
5635  if D2.get() > 0:
5636  devx.ctrl_transfer( 0x40, D2.get(), PIO_2, 0, 0, 0, 100) # set PIO 2
5637  if D2.get() == 0x50:
5638  digin2.configure(text="Low", background="#00ff00")
5639  else:
5640  digin2.configure(text="Hi", background="#ff0000")
5641  else:
5642  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100)
5643  if Dval[0] == 0:
5644  digin2.configure(text="Low", background="#00ff00")
5645  else:
5646  digin2.configure(text="Hi", background="#ff0000")
5647  if D3.get() > 0:
5648  devx.ctrl_transfer( 0x40, D3.get(), PIO_3, 0, 0, 0, 100) # set PIO 3
5649  if D3.get() == 0x50:
5650  digin3.configure(text="Low", background="#00ff00")
5651  else:
5652  digin3.configure(text="Hi", background="#ff0000")
5653  else:
5654  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100)
5655  if Dval[0] == 0:
5656  digin3.configure(text="Low", background="#00ff00")
5657  else:
5658  digin3.configure(text="Hi", background="#ff0000")
5659  if D4.get() > 0:
5660  devx.ctrl_transfer( 0x40, D4.get(), PIO_4, 0, 0, 0, 100) # set PIO 4
5661  if D4.get() == 0x50:
5662  digin4.configure(text="Low", background="#00ff00")
5663  else:
5664  digin4.configure(text="Hi", background="#ff0000")
5665  else:
5666  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100)
5667  if Dval[0] == 0:
5668  digin4.configure(text="Low", background="#00ff00")
5669  else:
5670  digin4.configure(text="Hi", background="#ff0000")
5671  if D5.get() > 0:
5672  devx.ctrl_transfer( 0x40, D5.get(), PIO_5, 0, 0, 0, 100) # set PIO 5
5673  if D5.get() == 0x50:
5674  digin5.configure(text="Low", background="#00ff00")
5675  else:
5676  digin5.configure(text="Hi", background="#ff0000")
5677  else:
5678  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100)
5679  if Dval[0] == 0:
5680  digin5.configure(text="Low", background="#00ff00")
5681  else:
5682  digin5.configure(text="Hi", background="#ff0000")
5683  if D6.get() > 0:
5684  devx.ctrl_transfer( 0x40, D6.get(), PIO_6, 0, 0, 0, 100) # set PIO 6
5685  if D6.get() == 0x50:
5686  digin6.configure(text="Low", background="#00ff00")
5687  else:
5688  digin6.configure(text="Hi", background="#ff0000")
5689  else:
5690  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100)
5691  if Dval[0] == 0:
5692  digin6.configure(text="Low", background="#00ff00")
5693  else:
5694  digin6.configure(text="Hi", background="#ff0000")
5695  if D7.get() > 0:
5696  devx.ctrl_transfer( 0x40, D7.get(), PIO_7, 0, 0, 0, 100) # set PIO 7
5697  if D7.get() == 0x50:
5698  digin7.configure(text="Low", background="#00ff00")
5699  else:
5700  digin7.configure(text="Hi", background="#ff0000")
5701  else:
5702  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100)
5703  if Dval[0] == 0:
5704  digin7.configure(text="Low", background="#00ff00")
5705  else:
5706  digin7.configure(text="Hi", background="#ff0000")
5707 
5708 
5710  global D0, D1, D2, D3, D4, D5, D6, D7
5711  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7
5712  global digin0, digin1, digin2, digin3, digin4, digin5, digin6, digin7
5713  global DigScreenStatus, DacScreenStatus, win2, MuxScreenStatus
5714  # setup Dig output window
5715  if DigScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
5716  DigScreenStatus.set(1)
5717  win2 = Toplevel()
5718  win2.title("Dig Out")
5719  win2.resizable(FALSE,FALSE)
5720  win2.protocol("WM_DELETE_WINDOW", DestroyDigScreen)
5721  drb1 = Radiobutton(win2, text="D0-0", variable=D0, value=0x50, command=sel )
5722  drb1.grid(row=2, column=0, sticky=W)
5723  drb0z = Radiobutton(win2, text="D0-Z", variable=D0, value=0, command=sel )
5724  drb0z.grid(row=2, column=1, sticky=W)
5725  drb2 = Radiobutton(win2, text="D0-1", variable=D0, value=0x51, command=sel )
5726  drb2.grid(row=2, column=2, sticky=W)
5727  digin0 = Label(win2, text="Low", background = "#00ff00")
5728  digin0.grid(row=2, column=3, sticky=W)
5729  drb3 = Radiobutton(win2, text="D1-0", variable=D1, value=0x50, command=sel )
5730  drb3.grid(row=3, column=0, sticky=W)
5731  drb3z = Radiobutton(win2, text="D1-Z", variable=D1, value=0, command=sel )
5732  drb3z.grid(row=3, column=1, sticky=W)
5733  drb4 = Radiobutton(win2, text="D1-1", variable=D1, value=0x51, command=sel )
5734  drb4.grid(row=3, column=2, sticky=W)
5735  digin1 = Label(win2, text="Low", background = "#00ff00")
5736  digin1.grid(row=3, column=3, sticky=W)
5737  drb5 = Radiobutton(win2, text="D2-0", variable=D2, value=0x50, command=sel )
5738  drb5.grid(row=4, column=0, sticky=W)
5739  drb5z = Radiobutton(win2, text="D2-Z", variable=D2, value=0, command=sel )
5740  drb5z.grid(row=4, column=1, sticky=W)
5741  drb6 = Radiobutton(win2, text="D2-1", variable=D2, value=0x51, command=sel )
5742  drb6.grid(row=4, column=2, sticky=W)
5743  digin2 = Label(win2, text="Low", background = "#00ff00")
5744  digin2.grid(row=4, column=3, sticky=W)
5745  drb7 = Radiobutton(win2, text="D3-0", variable=D3, value=0x50, command=sel )
5746  drb7.grid(row=5, column=0, sticky=W)
5747  drb7z = Radiobutton(win2, text="D3-Z", variable=D3, value=0, command=sel )
5748  drb7z.grid(row=5, column=1, sticky=W)
5749  drb8 = Radiobutton(win2, text="D3-1", variable=D3, value=0x51, command=sel )
5750  drb8.grid(row=5, column=2, sticky=W)
5751  digin3 = Label(win2, text="Low", background = "#00ff00")
5752  digin3.grid(row=5, column=3, sticky=W)
5753  drb9 = Radiobutton(win2, text="D4-0", variable=D4, value=0x50, command=sel )
5754  drb9.grid(row=6, column=0, sticky=W)
5755  drb9z = Radiobutton(win2, text="D4-Z", variable=D4, value=0, command=sel )
5756  drb9z.grid(row=6, column=1, sticky=W)
5757  drb10 = Radiobutton(win2, text="D4-1", variable=D4, value=0x51, command=sel )
5758  drb10.grid(row=6, column=2, sticky=W)
5759  digin4 = Label(win2, text="Low", background = "#00ff00")
5760  digin4.grid(row=6, column=3, sticky=W)
5761  drb11 = Radiobutton(win2, text="D5-0", variable=D5, value=0x50, command=sel )
5762  drb11.grid(row=7, column=0, sticky=W)
5763  drb11z = Radiobutton(win2, text="D5-Z", variable=D5, value=0, command=sel )
5764  drb11z.grid(row=7, column=1, sticky=W)
5765  drb12 = Radiobutton(win2, text="D5-1", variable=D5, value=0x51, command=sel )
5766  drb12.grid(row=7, column=2, sticky=W)
5767  digin5 = Label(win2, text="Low", background = "#00ff00")
5768  digin5.grid(row=7, column=3, sticky=W)
5769  drb13 = Radiobutton(win2, text="D6-0", variable=D6, value=0x50, command=sel )
5770  drb13.grid(row=8, column=0, sticky=W)
5771  drb13z = Radiobutton(win2, text="D6-Z", variable=D6, value=0, command=sel )
5772  drb13z.grid(row=8, column=1, sticky=W)
5773  drb13 = Radiobutton(win2, text="D6-1", variable=D6, value=0x51, command=sel )
5774  drb13.grid(row=8, column=2, sticky=W)
5775  digin6 = Label(win2, text="Low", background = "#00ff00")
5776  digin6.grid(row=8, column=3, sticky=W)
5777  drb14 = Radiobutton(win2, text="D7-0", variable=D7, value=0x50, command=sel )
5778  drb14.grid(row=9, column=0, sticky=W)
5779  drb14z = Radiobutton(win2, text="D7-Z", variable=D7, value=0, command=sel )
5780  drb14z.grid(row=9, column=1, sticky=W)
5781  drb15 = Radiobutton(win2, text="D7-1", variable=D7, value=0x51, command=sel )
5782  drb15.grid(row=9, column=2, sticky=W)
5783  digin7 = Label(win2, text="Low", background = "#00ff00")
5784  digin7.grid(row=9, column=3, sticky=W)
5785 
5786  digdismissbutton = Button(win2, text="Dismiss", command=DestroyDigScreen)
5787  digdismissbutton.grid(row=10, column=0, sticky=W)
5788 
5790  global win1, DacScreenStatus
5791 
5792  DacScreenStatus.set(0)
5793  win1.destroy()
5794 
5795 def sel0(temp):
5796  global devx, DevID
5797  global PIO_0, PIO_4
5798  global DAC0
5799  # sending 0x50 = set to 0, 0x51 = set to 1
5800  if DAC0.get() == 1:
5801  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5802  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4 0
5803  elif DAC0.get() == 4:
5804  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5805  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
5806  elif DAC0.get() == 2:
5807  devx.ctrl_transfer( 0x40, 0x50, PIO_0, 0, 0, 0, 100) # set PIO 0 0
5808  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5809  elif DAC0.get() == 3:
5810  Dval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO 0 Z
5811  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
5812  elif DAC0.get() == 5:
5813  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
5814  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5815  elif DAC0.get() == 7:
5816  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_0, 0, 0, 1, 100) # set PIO 0 Z
5817  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4 1
5818  elif DAC0.get() == 8:
5819  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0 1
5820  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_4, 0, 0, 1, 100) # set PIO 4 Z
5821  elif DAC0.get() == 6:
5822  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
5823  devx.ctrl_transfer( 0x40, 0x50, PIO_4, 0, 0, 0, 100) # set PIO 4
5824  elif DAC0.get() == 9:
5825  devx.ctrl_transfer( 0x40, 0x51, PIO_0, 0, 0, 0, 100) # set PIO 0
5826  devx.ctrl_transfer( 0x40, 0x51, PIO_4, 0, 0, 0, 100) # set PIO 4
5827 
5828 def sel1(temp):
5829  global devx, DevID
5830  global PIO_1, PIO_5
5831  global DAC1
5832  # sending 0x50 = set to 0, 0x51 = set to 1
5833  if DAC1.get() == 1:
5834  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5835  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4 0
5836  elif DAC1.get() == 4:
5837  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5838  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
5839  elif DAC1.get() == 2:
5840  devx.ctrl_transfer( 0x40, 0x50, PIO_1, 0, 0, 0, 100) # set PIO 0 0
5841  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5842  elif DAC1.get() == 3:
5843  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5844  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
5845  elif DAC1.get() == 5:
5846  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5847  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5848  elif DAC1.get() == 7:
5849  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_1, 0, 0, 1, 100) # set PIO 0 Z
5850  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4 1
5851  elif DAC1.get() == 8:
5852  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0 1
5853  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_5, 0, 0, 1, 100) # set PIO 4 Z
5854  elif DAC1.get() == 6:
5855  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
5856  devx.ctrl_transfer( 0x40, 0x50, PIO_5, 0, 0, 0, 100) # set PIO 4
5857  elif DAC1.get() == 9:
5858  devx.ctrl_transfer( 0x40, 0x51, PIO_1, 0, 0, 0, 100) # set PIO 0
5859  devx.ctrl_transfer( 0x40, 0x51, PIO_5, 0, 0, 0, 100) # set PIO 4
5860 
5861 def sel2(temp):
5862  global devx, DevID
5863  global PIO_2, PIO_6
5864  global DAC2
5865  # sending 0x50 = set to 0, 0x51 = set to 1
5866  if DAC2.get() == 1:
5867  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5868  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4 0
5869  elif DAC2.get() == 4:
5870  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5871  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5872  elif DAC2.get() == 2:
5873  devx.ctrl_transfer( 0x40, 0x50, PIO_2, 0, 0, 0, 100) # set PIO 0 0
5874  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5875  elif DAC2.get() == 3:
5876  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5877  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5878  elif DAC2.get() == 5:
5879  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5880  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5881  elif DAC2.get() == 7:
5882  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_2, 0, 0, 1, 100) # set PIO 0 Z
5883  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4 1
5884  elif DAC2.get() == 8:
5885  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0 1
5886  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_6, 0, 0, 1, 100) # set PIO 4 Z
5887  elif DAC2.get() == 6:
5888  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5889  devx.ctrl_transfer( 0x40, 0x50, PIO_6, 0, 0, 0, 100) # set PIO 4
5890  elif DAC2.get() == 9:
5891  devx.ctrl_transfer( 0x40, 0x51, PIO_2, 0, 0, 0, 100) # set PIO 0
5892  devx.ctrl_transfer( 0x40, 0x51, PIO_6, 0, 0, 0, 100) # set PIO 4
5893 
5894 def sel3(temp):
5895  global devx, DevID
5896  global PIO_3, PIO_7
5897  global DAC3
5898  # sending 0x50 = set to 0, 0x51 = set to 1
5899  if DAC3.get() == 1:
5900  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5901  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4 0
5902  elif DAC3.get() == 4:
5903  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5904  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5905  elif DAC3.get() == 2:
5906  devx.ctrl_transfer( 0x40, 0x50, PIO_3, 0, 0, 0, 100) # set PIO 0 0
5907  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5908  elif DAC3.get() == 3:
5909  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5910  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5911  elif DAC3.get() == 5:
5912  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5913  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5914  elif DAC3.get() == 7:
5915  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_3, 0, 0, 1, 100) # set PIO 0 Z
5916  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4 1
5917  elif DAC3.get() == 8:
5918  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0 1
5919  Dval = devx.ctrl_transfer( 0xc0, 0x91, PIO_7, 0, 0, 1, 100) # set PIO 4 Z
5920  elif DAC3.get() == 6:
5921  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5922  devx.ctrl_transfer( 0x40, 0x50, PIO_7, 0, 0, 0, 100) # set PIO 4
5923  elif DAC3.get() == 9:
5924  devx.ctrl_transfer( 0x40, 0x51, PIO_3, 0, 0, 0, 100) # set PIO 0
5925  devx.ctrl_transfer( 0x40, 0x51, PIO_7, 0, 0, 0, 100) # set PIO 4
5926 
5928  global DAC0, DAC1, DAC2, DAC3, SWRev, RevDate
5929  global DacScreenStatus, DigScreenStatus, win1, MuxScreenStatus
5930  # setup Dig output window
5931  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0 and MuxScreenStatus.get() == 0:
5932  DacScreenStatus.set(1)
5933  win1 = Toplevel()
5934  win1.title("DAC Out "+ SWRev + RevDate)
5935  win1.resizable(FALSE,FALSE)
5936  win1.protocol("WM_DELETE_WINDOW", DestroyDacScreen)
5937  DAC0 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel0, length=90)
5938  DAC0.grid(row=0, column=0, sticky=W)
5939  DAC1 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel1, length=90)
5940  DAC1.grid(row=0, column=1, sticky=W)
5941  DAC2 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel2, length=90)
5942  DAC2.grid(row=0, column=2, sticky=W)
5943  DAC3 = Scale(win1, from_=9, to=1, orient=VERTICAL, command=sel3, length=90)
5944  DAC3.grid(row=0, column=3, sticky=W)
5945 
5946  dismissbutton = Button(win1, text="Dismiss", command=DestroyDacScreen)
5947  dismissbutton.grid(row=1, column=0, columnspan=4, sticky=W)
5948 
5950 
5951  MakeTimeTrace() # Update the traces
5952  UpdateTimeScreen() # Update the screen
5953 
5955 
5956  MakeTimeTrace() # Update traces
5957  UpdateTimeScreen() # Update the screen
5958 
5960 
5961  MakeTimeScreen() # Update the screen
5962  root.update() # Activate updated screens
5963 
5965 
5966  MakeXYTrace() # Update the traces
5967  UpdateXYScreen() # Update the screen
5968 
5970 
5971  MakeXYTrace() # Update traces
5972  UpdateXYScreen() # Update the screen
5973 
5975 
5976  MakeXYScreen() # Update the screen
5977  root.update() # Activate updated screens
5978 
5980  global VBuffA, VBuffB, IBuffA, IBuffB
5981  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
5982  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
5983  global VmemoryMuxA, VmemoryMuxB, VmemoryMuxC, VmemoryMuxD
5984  global DBuff0, DBuff1, DBuff2, DBuff3, D0, D1, D2, D3
5985  global D0line, D1line, D2line, D3line
5986  global FFTBuffA, FFTBuffB, FFTwindowshape
5987  global AWGAwaveform, AWGBwaveform
5988  global T1Vline, T2Vline, T1Iline, T2Iline
5989  global TMAVline, TMBVline, TMCVline, TMDVline
5990  global Tmathline, TMXline, TMYline
5991  global MathString, MathAxis, MathXString, MathYString, MathXAxis, MathYAxis
5992  global Triggerline, Triggersymbol, TgInput, TgEdge, HoldOff, HoldOffentry
5993  global X0L, Y0T, GRW, GRH, MouseX, MouseY, MouseCAV, MouseCAI, MouseCBV, MouseCBI
5994  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
5995  global SHOWsamples, ZOHold, AWGBMode
5996  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
5997  global Show_CBA, Show_CBB, Show_CBC, Show_CBD
5998  global Show_MathX, Show_MathY
5999  global TRACES, TRACESread, RUNstatus
6000  global AutoCenterA, AutoCenterB
6001  global CHAsb, CHBsb, CHAOffset, CHBOffset, CHAIsb, CHBIsb, CHAIOffset, CHBIOffset
6002  global TMpdiv # Array with time / div values in ms
6003  global TMsb # Time per div spin box variable
6004  global TIMEdiv # current spin box value
6005  global SAMPLErate, SCstart, Two_X_Sample, DISsamples, First_Slow_sweep
6006  global TRIGGERsample, TRACEsize, DX, TRIGGERsampleAltA, TRIGGERsampleAltB
6007  global TRIGGERlevel, TRIGGERentry, AutoLevel
6008  global InOffA, InGainA, InOffB, InGainB
6009  global CurOffA, CurOffB, CurGainA, CurGainB
6010  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
6011  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
6012  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
6013  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
6014  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
6015  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
6016  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
6017  global HozPoss, HozPossentry
6018 
6019  # Set the TRACEsize variable
6020  if len(VBuffA) < 100 and MuxScreenStatus.get() == 0:
6021  return
6022  TRACEsize = SHOWsamples # Set the trace length
6023  SCstart = 0
6024  ylo = 0.0
6025  xlo = 0.0
6026  Ymin = Y0T # Minimum position of time grid (top)
6027  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
6028  Xmin = X0L # Minimum position of time grid (left)
6029  Xmax = X0L + GRW # Maximum position of time grid (right)
6030 
6031  # prevent divide by zero error
6032  if TIMEdiv < 0.0002:
6033  TIMEdiv = 0.01
6034  # Check for Auto Centering
6035  if AutoCenterA.get() > 0:
6036  CHAOffset = DCV1
6037  CHAVPosEntry.delete(0,END)
6038  CHAVPosEntry.insert(0, ' {0:.2f} '.format(CHAOffset))
6039  if AutoCenterB.get() > 0:
6040  CHBOffset = DCV2
6041  CHBVPosEntry.delete(0,END)
6042  CHBVPosEntry.insert(0, ' {0:.2f} '.format(CHBOffset))
6043  # get the vertical ranges
6044  try:
6045  CH1pdvRange = float(eval(CHAsb.get()))
6046  except:
6047  CHAsb.delete(0,END)
6048  CHAsb.insert(0, CH1pdvRange)
6049  try:
6050  CH2pdvRange = float(eval(CHBsb.get()))
6051  except:
6052  CHBsb.delete(0,END)
6053  CHBsb.insert(0, CH2pdvRange)
6054  try:
6055  CH1IpdvRange = float(eval(CHAIsb.get()))
6056  except:
6057  CHAIsb.delete(0,END)
6058  CHAIsb.insert(0, CH1IpdvRange)
6059  try:
6060  CH2IpdvRange = float(eval(CHBIsb.get()))
6061  except:
6062  CHBIsb.delete(0,END)
6063  CHBIsb.insert(0, CH2IpdvRange)
6064  # get the vertical offsets
6065  try:
6066  CHAOffset = float(eval(CHAVPosEntry.get()))
6067  except:
6068  CHAVPosEntry.delete(0,END)
6069  CHAVPosEntry.insert(0, CHAOffset)
6070  try:
6071  CHAIOffset = float(eval(CHAIPosEntry.get()))
6072  except:
6073  CHAIPosEntry.delete(0,END)
6074  CHAIPosEntry.insert(0, CHAIOffset)
6075  try:
6076  CHBOffset = float(eval(CHBVPosEntry.get()))
6077  except:
6078  CHBVPosEntry.delete(0,END)
6079  CHBVPosEntry.insert(0, CHBOffset)
6080  try:
6081  CHBIOffset = float(eval(CHBIPosEntry.get()))
6082  except:
6083  CHBIPosEntry.delete(0,END)
6084  CHBIPosEntry.insert(0, CHBIOffset)
6085  # prevent divide by zero error
6086  if CH1pdvRange < 0.001:
6087  CH1pdvRange = 0.001
6088  if CH2pdvRange < 0.001:
6089  CH2pdvRange = 0.001
6090  if CH1IpdvRange < 0.1:
6091  CH1IpdvRange = 0.1
6092  if CH2IpdvRange < 0.1:
6093  CH2IpdvRange = 0.1
6094 #
6095  try:
6096  HoldOff = float(eval(HoldOffentry.get()))
6097  if HoldOff < 0:
6098  HoldOff = 0
6099  HoldOffentry.delete(0,END)
6100  HoldOffentry.insert(0, HoldOff)
6101  except:
6102  HoldOffentry.delete(0,END)
6103  HoldOffentry.insert(0, HoldOff)
6104 #
6105  try:
6106  HozPoss = float(eval(HozPossentry.get()))
6107  except:
6108  HozPossentry.delete(0,END)
6109  HozPossentry.insert(0, HozPoss)
6110 #
6111  hldn = int(HoldOff * SAMPLErate/1000 )
6112  hozpos = int(HozPoss * SAMPLErate/1000 )
6113  if hozpos < 0:
6114  hozpos = 0
6115  # drawing the traces
6116  if TRACEsize == 0: # If no trace, skip rest of this routine
6117  T1Vline = [] # Trace line channel A V
6118  T2Vline = [] # Trace line channel B V
6119  T1Iline = []
6120  T2Iline = []
6121  TMAVline = [] # V Trace line Mux channel A
6122  TMBVline = [] # V Trace line Mux channel B
6123  TMCVline = [] # V Trace line Mux channel C
6124  TMDVline = [] # V Trace line Mux channel D
6125  Tmathline = [] # math trce line
6126  return()
6127 
6128  # set and/or corrected for in range
6129  if TgInput.get() > 0 or ChopTrig.get() > 0:
6130  SCmin = int(-1 * TRIGGERsample)
6131  SCmax = int(TRACEsize - TRIGGERsample - 0)
6132  else:
6133  SCmin = 0 # hldn
6134  SCmax = TRACEsize - 1
6135  if SCstart < SCmin: # No reading before start of array
6136  SCstart = SCmin
6137  if SCstart > SCmax: # No reading after end of array
6138  SCstart = SCmax
6139 
6140  # Make Trace lines etc.
6141 
6142  Yconv1 = float(GRH/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
6143  Yconv2 = float(GRH/10.0) / CH2pdvRange
6144  YIconv1 = float(GRH/10.0) / CH1IpdvRange
6145  YIconv2 = float(GRH/10.0) / CH2IpdvRange
6146  Xconv1 = float(GRW/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
6147  Xconv2 = float(GRW/10.0) / CH2pdvRange
6148  XIconv1 = float(GRW/10.0) / CH1IpdvRange
6149  XIconv2 = float(GRW/10.0) / CH2IpdvRange
6150  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
6151  try:
6152  CHMApdvRange = float(eval(CHB_Asb.get()))
6153  except:
6154  CHB_Asb.delete(0,END)
6155  CHB_Asb.insert(0, CHMApdvRange)
6156  try:
6157  CHMBpdvRange = float(eval(CHB_Bsb.get()))
6158  except:
6159  CHB_Bsb.delete(0,END)
6160  CHB_Bsb.insert(0, CHMBpdvRange)
6161  try:
6162  CHMCpdvRange = float(eval(CHB_Csb.get()))
6163  except:
6164  CHB_Csb.delete(0,END)
6165  CHB_Csb.insert(0, CHMCpdvRange)
6166  try:
6167  CHMDpdvRange = float(eval(CHB_Dsb.get()))
6168  except:
6169  CHB_Dsb.delete(0,END)
6170  CHB_Dsb.insert(0, CHMDpdvRange)
6171  YconvMA = float(GRH/10.0) / CHMApdvRange
6172  YconvMB = float(GRH/10.0) / CHMBpdvRange
6173  YconvMC = float(GRH/10.0) / CHMCpdvRange
6174  YconvMD = float(GRH/10.0) / CHMDpdvRange
6175  try:
6176  CHBAOffset = float(eval(CHB_APosEntry.get()))
6177  except:
6178  CHB_APosEntry.delete(0,END)
6179  CHB_APosEntry.insert(0, CHBAOffset)
6180  try:
6181  CHBBOffset = float(eval(CHB_BPosEntry.get()))
6182  except:
6183  CHB_BPosEntry.delete(0,END)
6184  CHB_BPosEntry.insert(0, CHBBOffset)
6185  try:
6186  CHBCOffset = float(eval(CHB_CPosEntry.get()))
6187  except:
6188  CHB_CPosEntry.delete(0,END)
6189  CHB_CPosEntry.insert(0, CHBCOffset)
6190  try:
6191  CHBDOffset = float(eval(CHB_DPosEntry.get()))
6192  except:
6193  CHB_DPosEntry.delete(0,END)
6194  CHB_DPosEntry.insert(0, CHBDOffset)
6195  if MathAxis == "V-A":
6196  YconvM = Yconv1
6197  CHMOffset = CHAOffset
6198  elif MathAxis == "V-B":
6199  YconvM = Yconv2
6200  CHMOffset = CHBOffset
6201  elif MathAxis == "I-A":
6202  YconvM = YIconv1
6203  CHMOffset = CHAIOffset
6204  elif MathAxis == "I-B":
6205  YconvM = YIconv2
6206  CHMOffset = CHBIOffset
6207  else:
6208  YconvM = Yconv1
6209  CHMOffset = CHAOffset
6210 # include ploting X and Y math formulas vs time
6211  if MathYAxis == "V-A":
6212  YconvMxy = Yconv1
6213  CHMYOffset = CHAOffset
6214  elif MathYAxis == "V-B":
6215  YconvMxy = Yconv2
6216  CHMYOffset = CHBOffset
6217  elif MathYAxis == "I-A":
6218  YconvMxy = YIconv1
6219  CHMYOffset = CHAIOffset
6220  elif MathYAxis == "I-B":
6221  YconvMxy = YIconv2
6222  CHMYOffset = CHBIOffset
6223  else:
6224  YconvMxy = Yconv1
6225  CHMYOffset = CHAOffset
6226 #
6227  if MathXAxis == "V-A":
6228  XconvMxy = Yconv1
6229  CHMXOffset = CHAOffset
6230  elif MathXAxis == "V-B":
6231  XconvMxy = Yconv2
6232  CHMXOffset = CHBOffset
6233  elif MathXAxis == "I-A":
6234  XconvMxy = YIconv1
6235  CHMXOffset = CHAIOffset
6236  elif MathXAxis == "I-B":
6237  XconvMxy = YIconv2
6238  CHMXOffset = CHBIOffset
6239  else:
6240  XconvMxy = Yconv1
6241  CHMXOffset = CHAOffset
6242 #
6243  c1 = GRH / 2.0 + Y0T # fixed correction channel A
6244  c2 = GRH / 2.0 + Y0T # fixed correction channel B
6245 
6246  if First_Slow_sweep == 1:
6247  TRACEsize = len(VBuffA)
6248  DISsamples = GRW
6249  D0line = []
6250  D1line = []
6251  D2line = []
6252  D3line = []
6253  Dconv = float(GRH/10.0) # pixels per Div
6254  else:
6255  DISsamples = SAMPLErate * 10.0 * TIMEdiv / 1000.0 # number of samples to display
6256  T1Vline = [] # V Trace line channel A
6257  T2Vline = [] # V Trace line channel B
6258  T1Iline = [] # I Trace line channel A
6259  T2Iline = [] # I Trace line channel B
6260  TMAVline = [] # V Trace line Mux channel A
6261  TMBVline = [] # V Trace line Mux channel B
6262  TMCVline = [] # V Trace line Mux channel C
6263  TMDVline = [] # V Trace line Mux channel D
6264  Tmathline = [] # math trce line
6265  TMXline = [] # X math Trace line
6266  TMYline = [] # Y math Trace line
6267  if len(VBuffA) < 4 and len(VBuffB) < 4 and len(IBuffA) < 4 and len(IBuffB) < 4:
6268  return
6269  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6270  if t < 0:
6271  t = 0
6272  x = 0 # Horizontal screen pixel
6273 #
6274  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6275  ypi1 = int(c1 - YIconv1 * (IBuffA[t] - CHAIOffset))
6276  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6277  ypi2 = int(c1 - YIconv2 * (IBuffB[t] - CHBIOffset))
6278  DvY1 = DvY2 = DiY1 = DiY2 = 0
6279 #
6280  if (DISsamples <= GRW):
6281  Xstep = GRW / DISsamples
6282  if AWGBMode.get() == 2 and Two_X_Sample.get() == 0:
6283  xa = int((Xstep/-2.5) - (Xstep*DX))
6284  else:
6285  xa = 0 - int(Xstep*DX) # adjust start pixel for interpolated trigger point
6286  x = 0 - int(Xstep*DX)
6287  Tstep = 1
6288  x1 = 0 # x position of trace line
6289  xa1 = 0
6290  y1 = 0.0 # y position of trace line
6291  ypv1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6292  ytemp = IBuffA[t]
6293  ypi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6294  ypv2 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6295  if MuxScreenStatus.get() == 1:
6296  if len(VBuffMA) > 4:
6297  ypvma = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6298  if len(VBuffMB) > 4:
6299  ypvmb = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6300  if len(VBuffMC) > 4:
6301  ypvmc = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6302  if len(VBuffMD) > 4:
6303  ypvmd = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6304  ytemp = IBuffB[t]
6305  ypi2 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6306  ypm = ypmx = ypmy = GRH / 2.0 + Y0T
6307  if TgInput.get() == 0:
6308  Xlimit = GRW
6309  else:
6310  Xlimit = GRW+Xstep
6311  while x <= Xlimit:
6312  if t < TRACEsize:
6313  xa1 = xa + X0L
6314  x1 = x + X0L
6315  y1 = int(c1 - Yconv1 * (VBuffA[t] - CHAOffset))
6316  ytemp = IBuffA[t]
6317  yi1 = int(c1 - YIconv1 * (ytemp - CHAIOffset))
6318 
6319  if y1 < Ymin: # clip waveform if going off grid
6320  y1 = Ymin
6321  if y1 > Ymax:
6322  y1 = Ymax
6323  if yi1 < Ymin:
6324  yi1 = Ymin
6325  if yi1 > Ymax:
6326  yi1 = Ymax
6327  if ShowC1_V.get() == 1 :
6328  if ZOHold.get() == 1:
6329  T1Vline.append(int(xa1))
6330  T1Vline.append(int(ypv1))
6331  T1Vline.append(int(xa1))
6332  T1Vline.append(int(y1))
6333  else:
6334  T1Vline.append(int(xa1))
6335  T1Vline.append(int(y1))
6336  DvY1 = ypv1 - y1
6337  ypv1 = y1
6338  if ShowC1_I.get() == 1:
6339  if ZOHold.get() == 1:
6340  T1Iline.append(int(xa1))
6341  T1Iline.append(int(ypi1))
6342  T1Iline.append(int(xa1))
6343  T1Iline.append(int(yi1))
6344  else:
6345  T1Iline.append(int(xa1))
6346  T1Iline.append(int(yi1))
6347  DiY1 = ypi1 - yi1
6348  ypi1 = yi1
6349  if ShowC2_V.get() == 1:
6350  y1 = int(c2 - Yconv2 * (VBuffB[t] - CHBOffset))
6351  if y1 < Ymin: # clip waveform if going off grid
6352  y1 = Ymin
6353  if y1 > Ymax:
6354  y1 = Ymax
6355  if ZOHold.get() == 1:
6356  T2Vline.append(int(x1))
6357  T2Vline.append(int(ypv2))
6358  T2Vline.append(int(x1))
6359  T2Vline.append(int(y1))
6360  else:
6361  T2Vline.append(int(x1))
6362  T2Vline.append(int(y1))
6363  DvY2 = ypv2 - y1
6364  ypv2 = y1
6365  if Show_CBA.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMA)>4:
6366  y1 = int(c2 - YconvMA * (VBuffMA[t] - CHBAOffset))
6367  if y1 < Ymin: # clip waveform if going off grid
6368  y1 = Ymin
6369  if y1 > Ymax:
6370  y1 = Ymax
6371  if ZOHold.get() == 1:
6372  TMAVline.append(int(x1))
6373  TMAVline.append(int(ypvma))
6374  TMAVline.append(int(x1))
6375  TMAVline.append(int(y1))
6376  else:
6377  TMAVline.append(int(x1))
6378  TMAVline.append(int(y1))
6379  ypvma = y1
6380  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6381  Xfine = MouseX - X0L - x
6382  MouseMuxA = ypvma - (y1 - ypvma) * (Xfine/Xstep)
6383  if Show_CBB.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMB)>4:
6384  y1 = int(c2 - YconvMB * (VBuffMB[t] - CHBBOffset))
6385  if y1 < Ymin: # clip waveform if going off grid
6386  y1 = Ymin
6387  if y1 > Ymax:
6388  y1 = Ymax
6389  if ZOHold.get() == 1:
6390  TMBVline.append(int(x1))
6391  TMBVline.append(int(ypvmb))
6392  TMBVline.append(int(x1))
6393  TMBVline.append(int(y1))
6394  else:
6395  TMBVline.append(int(x1))
6396  TMBVline.append(int(y1))
6397  ypvmb = y1
6398  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6399  Xfine = MouseX - X0L - x
6400  MouseMuxB = ypvmb - (y1 - ypvmb) * (Xfine/Xstep)
6401  if Show_CBC.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMC)>4:
6402  y1 = int(c2 - YconvMC * (VBuffMC[t] - CHBCOffset))
6403  if y1 < Ymin: # clip waveform if going off grid
6404  y1 = Ymin
6405  if y1 > Ymax:
6406  y1 = Ymax
6407  if ZOHold.get() == 1:
6408  TMCVline.append(int(x1))
6409  TMCVline.append(int(ypvmc))
6410  TMCVline.append(int(x1))
6411  TMCVline.append(int(y1))
6412  else:
6413  TMCVline.append(int(x1))
6414  TMCVline.append(int(y1))
6415  ypvmc = y1
6416  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6417  Xfine = MouseX - X0L - x
6418  MouseMuxC = ypvmc - (y1 - ypvmc) * (Xfine/Xstep)
6419  if Show_CBD.get() == 1 and MuxScreenStatus.get() == 1 and len(VBuffMD)>4:
6420  y1 = int(c2 - YconvMD * (VBuffMD[t] - CHBDOffset))
6421  if y1 < Ymin: # clip waveform if going off grid
6422  y1 = Ymin
6423  if y1 > Ymax:
6424  y1 = Ymax
6425  if ZOHold.get() == 1:
6426  TMDVline.append(int(x1))
6427  TMDVline.append(int(ypvmd))
6428  TMDVline.append(int(x1))
6429  TMDVline.append(int(y1))
6430  else:
6431  TMDVline.append(int(x1))
6432  TMDVline.append(int(y1))
6433  ypvmd = y1
6434  if (MouseX - X0L) >= x and (MouseX - X0L) < (x + Xstep):
6435  Xfine = MouseX - X0L - x
6436  MouseMuxD = ypvmd - (y1 - ypvmd) * (Xfine/Xstep)
6437  if ShowC2_I.get() == 1:
6438  ytemp = IBuffB[t]
6439  yi1 = int(c1 - YIconv2 * (ytemp - CHBIOffset))
6440  if yi1 < Ymin:
6441  yi1 = Ymin
6442  if yi1 > Ymax:
6443  yi1 = Ymax
6444  if (ZOHold.get() == 1):
6445  T2Iline.append(int(x1))
6446  T2Iline.append(int(ypi2))
6447  T2Iline.append(int(x1))
6448  T2Iline.append(int(yi1))
6449  else:
6450  T2Iline.append(int(x1))
6451  T2Iline.append(int(yi1))
6452  DiY2 = ypi2 - yi1
6453  ypi2 = yi1
6454  if MathTrace.get() > 0:
6455  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6456  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6457 
6458  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6459  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6460 
6461  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6462  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6463 
6464  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
6465  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
6466  ytemp = YIconv1 * (Ypower - CHAIOffset)
6467  y1 = int(c1 - ytemp)
6468 
6469  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
6470  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
6471  ytemp = YIconv2 * (Ypower - CHBIOffset)
6472  y1 = int(c2 - ytemp)
6473 
6474  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
6475  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
6476  ytemp = YIconv1 * (Yohms - CHAIOffset)
6477  y1 = int(c1 - ytemp)
6478 
6479  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
6480  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
6481  ytemp = YIconv2 * (Yohms - CHBIOffset)
6482  y1 = int(c2 - ytemp)
6483 
6484  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
6485  Ydif = (IBuffA[t] - IBuffB[t])# in mA
6486  ytemp = YIconv1 * (Ydif - CHAIOffset)
6487  y1 = int(c2 - ytemp)
6488 
6489  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6490  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6491  ytemp = YIconv2 * (Ydif - CHBIOffset)
6492  y1 = int(c2 - ytemp)
6493 
6494  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6495  try:
6496  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6497  except:
6498  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6499 
6500  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6501  try:
6502  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6503  except:
6504  Y1 = (IBuffB[t] / 0.000001)
6505  ytemp = YIconv2 * (Y1 - CHBIOffset)
6506  y1 = int(c2 - ytemp)
6507 
6508  elif MathTrace.get() == 12: # plot from equation string
6509  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6510  try:
6511  MathResult = eval(MathString)
6512  MathResult = MathResult - CHMOffset
6513  y1 = int(c1 - YconvM * MathResult)
6514  except:
6515  RUNstatus.set(0)
6516  x = Xlimit + 1 # exit loop
6517 
6518  if y1 < Ymin: # clip waveform if going off grid
6519  y1 = Ymin
6520  if y1 > Ymax:
6521  y1 = Ymax
6522  if ZOHold.get() == 1: # connet the dots with stair step
6523  Tmathline.append(int(x1))
6524  Tmathline.append(int(ypm))
6525  Tmathline.append(int(x1))
6526  Tmathline.append(int(y1))
6527  else: # connet the dots with single line
6528  Tmathline.append(int(x1))
6529  Tmathline.append(int(y1))
6530  ypm = y1
6531  if Show_MathX.get() > 0:
6532  try:
6533  MathResult = eval(MathXString)
6534  MathResult = MathResult - CHMXOffset
6535  y1 = int(c1 - XconvMxy * MathResult)
6536  except:
6537  RUNstatus.set(0)
6538  x = Xlimit + 1 # exit loop
6539 
6540  if y1 < Ymin: # clip waveform if going off grid
6541  y1 = Ymin
6542  if y1 > Ymax:
6543  y1 = Ymax
6544  if ZOHold.get() == 1: # connet the dots with stair step
6545  TMXline.append(int(x1))
6546  TMXline.append(int(ypmx))
6547  TMXline.append(int(x1))
6548  TMXline.append(int(y1))
6549  else: # connet the dots with single line
6550  TMXline.append(int(x1))
6551  TMXline.append(int(y1))
6552  ypmx = y1
6553  if Show_MathY.get() > 0:
6554  try:
6555  MathResult = eval(MathYString)
6556  MathResult = MathResult - CHMYOffset
6557  y1 = int(c1 - YconvMxy * MathResult)
6558  except:
6559  RUNstatus.set(0)
6560  x = Xlimit + 1 # exit loop
6561 
6562  if y1 < Ymin: # clip waveform if going off grid
6563  y1 = Ymin
6564  if y1 > Ymax:
6565  y1 = Ymax
6566  if ZOHold.get() == 1: # connet the dots with stair step
6567  TMYline.append(int(x1))
6568  TMYline.append(int(ypmy))
6569  TMYline.append(int(x1))
6570  TMYline.append(int(y1))
6571  else: # connet the dots with single line
6572  TMYline.append(int(x1))
6573  TMYline.append(int(y1))
6574  ypmy = y1
6575  if D0.get() == 0:
6576  yd = int(c1 - (( DBuff0[t]*0.9 - 5 ) * Dconv))
6577  D0line.append(int(x1))
6578  D0line.append(yd)
6579  if D1.get() == 0:
6580  yd = int(c1 - (( DBuff1[t]*0.9 - 4 ) * Dconv))
6581  D1line.append(int(x1))
6582  D1line.append(yd)
6583  if D2.get() == 0:
6584  yd = int(c1 - (( DBuff2[t]*0.9 - 3 ) * Dconv))
6585  D2line.append(int(x1))
6586  D2line.append(yd)
6587  if D3.get() == 0:
6588  yd = int(c1 - (( DBuff3[t]*0.9 - 2 ) * Dconv))
6589  D3line.append(int(x1))
6590  D3line.append(yd)
6591 
6592  # remember trace verticle pixel at X mouse location
6593  if MouseX - X0L >= x and MouseX - X0L < (x + Xstep): # - Xstep
6594  Xfine = MouseX - X0L - x
6595  MouseCAV = ypv1 - (DvY1 * (Xfine/Xstep)) # interpolate along yaxis
6596  MouseCAI = ypi1 - (DiY1 * (Xfine/Xstep))
6597  MouseCBV = ypv2 - (DvY2 * (Xfine/Xstep))
6598  MouseCBI = ypi2 - (DiY2 * (Xfine/Xstep))
6599  t = int(t + Tstep)
6600  x = x + Xstep
6601  xa = xa + Xstep
6602 
6603  else: #if (DISsamples > GRW): # if the number of samples is larger than the grid width need to ship over samples
6604  Xstep = 1
6605  Tstep = DISsamples / GRW # number of samples to skip per grid pixel
6606  x1 = 0.0 # x position of trace line
6607  ylo = 0.0 # ymin position of trace 1 line
6608  yhi = 0.0 # ymax position of trace 1 line
6609 
6610  t = int(SCstart + TRIGGERsample) # - (TriggerPos * SAMPLErate) # t = Start sample in trace
6611  if t > len(VBuffA)-1:
6612  t = 0
6613  if t < 0:
6614  t = 0
6615  x = 0 # Horizontal screen pixel
6616  ft = t # time point with fractions
6617  while (x <= GRW):
6618  if (t < TRACEsize):
6619  if (t >= len(VBuffA)):
6620  t = len(VBuffA)-2
6621  x = GRW
6622  x1 = x + X0L
6623  ylo = VBuffA[t] - CHAOffset
6624  ilo = IBuffA[t] - CHAIOffset
6625  yhi = ylo
6626  ihi = ilo
6627  n = t
6628  while n < (t + Tstep) and n < TRACEsize:
6629  if ( ShowC1_V.get() == 1 ):
6630  v = VBuffA[t] - CHAOffset
6631  if v < ylo:
6632  ylo = v
6633  if v > yhi:
6634  yhi = v
6635  if ( ShowC1_I.get() == 1 ):
6636  i = IBuffA[t] - CHAIOffset
6637  if i < ilo:
6638  ilo = i
6639  if i > ihi:
6640  ihi = i
6641  n = n + 1
6642  if ( ShowC1_V.get() == 1 ):
6643  ylo = int(c1 - Yconv1 * ylo)
6644  yhi = int(c1 - Yconv1 * yhi)
6645  if (ylo < Ymin):
6646  ylo = Ymin
6647  if (ylo > Ymax):
6648  ylo = Ymax
6649  if (yhi < Ymin):
6650  yhi = Ymin
6651  if (yhi > Ymax):
6652  yhi = Ymax
6653  T1Vline.append(int(x1))
6654  T1Vline.append(int(ylo))
6655  T1Vline.append(int(x1))
6656  T1Vline.append(int(yhi))
6657  ypv1 = ylo
6658  if ( ShowC1_I.get() == 1 ):
6659  ilo = int(c1 - YIconv1 * ilo)
6660  ihi = int(c1 - YIconv1 * ihi)
6661  if (ilo < Ymin):
6662  ilo = Ymin
6663  if (ilo > Ymax):
6664  ilo = Ymax
6665  if (ihi < Ymin):
6666  ihi = Ymin
6667  if (ihi > Ymax):
6668  ihi = Ymax
6669  T1Iline.append(int(x1))
6670  T1Iline.append(int(ilo))
6671  T1Iline.append(int(x1))
6672  T1Iline.append(int(ihi))
6673  ypi1 = ilo
6674  ylo = VBuffB[t] - CHBOffset
6675  ilo = IBuffB[t] - CHBIOffset
6676  yhi = ylo
6677  ihi = ilo
6678  n = t
6679  if MuxScreenStatus.get() == 0:
6680  while n < (t + Tstep) and n < TRACEsize:
6681  if ( ShowC2_V.get() == 1 ):
6682  v = VBuffB[t] - CHBOffset
6683  if v < ylo:
6684  ylo = v
6685  if v > yhi:
6686  yhi = v
6687  if ( ShowC2_I.get() == 1 ):
6688  i = IBuffB[t] - CHBIOffset
6689  if i < ilo:
6690  ilo = i
6691  if i > ihi:
6692  ihi = i
6693  n = n + 1
6694  if ( ShowC2_V.get() == 1 ):
6695  ylo = int(c2 - Yconv2 * ylo)
6696  yhi = int(c2 - Yconv2 * yhi)
6697  if (ylo < Ymin):
6698  ylo = Ymin
6699  if (ylo > Ymax):
6700  ylo = Ymax
6701 
6702  if (yhi < Ymin):
6703  yhi = Ymin
6704  if (yhi > Ymax):
6705  yhi = Ymax
6706  T2Vline.append(int(x1))
6707  T2Vline.append(int(ylo))
6708  T2Vline.append(int(x1))
6709  T2Vline.append(int(yhi))
6710  ypv2 = ylo
6711  if ( ShowC2_I.get() == 1 ):
6712  ilo = int(c2 - YIconv2 * ilo)
6713  ihi = int(c2 - YIconv2 * ihi)
6714  if (ilo < Ymin):
6715  ilo = Ymin
6716  if (ilo > Ymax):
6717  ilo = Ymax
6718  if (ihi < Ymin):
6719  ihi = Ymin
6720  if (ihi > Ymax):
6721  ihi = Ymax
6722  T2Iline.append(int(x1))
6723  T2Iline.append(int(ilo))
6724  T2Iline.append(int(x1))
6725  T2Iline.append(int(ihi))
6726  ypi2 = ilo
6727  else:
6728  if Show_CBA.get() == 1 and len(VBuffMA)>4:
6729  if t < len(VBuffMA):
6730  ylo = VBuffMA[t] - CHBAOffset
6731  yhi = ylo
6732  n = t
6733  while n < (t + Tstep) and n < len(VBuffMA):
6734  v = VBuffMA[t] - CHBAOffset
6735  if v < ylo:
6736  ylo = v
6737  if v > yhi:
6738  yhi = v
6739  n = n + 1
6740  ylo = int(c2 - YconvMA * ylo)
6741  yhi = int(c2 - YconvMA * yhi)
6742  if (ylo < Ymin):
6743  ylo = Ymin
6744  if (ylo > Ymax):
6745  ylo = Ymax
6746  if (yhi < Ymin):
6747  yhi = Ymin
6748  if (yhi > Ymax):
6749  yhi = Ymax
6750  TMAVline.append(int(x1))
6751  TMAVline.append(int(ylo))
6752  TMAVline.append(int(x1))
6753  TMAVline.append(int(yhi))
6754  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6755  MouseMuxA = ylo
6756  if Show_CBB.get() == 1 and len(VBuffMB)>4:
6757  if t < len(VBuffMB):
6758  ylo = VBuffMB[t] - CHBBOffset
6759  yhi = ylo
6760  n = t
6761  while n < (t + Tstep) and n < len(VBuffMB):
6762  v = VBuffMB[t] - CHBBOffset
6763  if v < ylo:
6764  ylo = v
6765  if v > yhi:
6766  yhi = v
6767  n = n + 1
6768  ylo = int(c2 - YconvMB * ylo)
6769  yhi = int(c2 - YconvMB * yhi)
6770  if (ylo < Ymin):
6771  ylo = Ymin
6772  if (ylo > Ymax):
6773  ylo = Ymax
6774  if (yhi < Ymin):
6775  yhi = Ymin
6776  if (yhi > Ymax):
6777  yhi = Ymax
6778  TMBVline.append(int(x1))
6779  TMBVline.append(int(ylo))
6780  TMBVline.append(int(x1))
6781  TMBVline.append(int(yhi))
6782  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6783  MouseMuxB = ylo
6784  if Show_CBC.get() == 1 and len(VBuffMC)>4:
6785  if t < len(VBuffMC):
6786  ylo = VBuffMC[t] - CHBCOffset
6787  yhi = ylo
6788  n = t
6789  while n < (t + Tstep) and n < len(VBuffMC):
6790  v = VBuffMC[t] - CHBCOffset
6791  if v < ylo:
6792  ylo = v
6793  if v > yhi:
6794  yhi = v
6795  n = n + 1
6796  ylo = int(c2 - YconvMC * ylo)
6797  yhi = int(c2 - YconvMC * yhi)
6798  if (ylo < Ymin):
6799  ylo = Ymin
6800  if (ylo > Ymax):
6801  ylo = Ymax
6802  if (yhi < Ymin):
6803  yhi = Ymin
6804  if (yhi > Ymax):
6805  yhi = Ymax
6806  TMCVline.append(int(x1))
6807  TMCVline.append(int(ylo))
6808  TMCVline.append(int(x1))
6809  TMCVline.append(int(yhi))
6810  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6811  MouseMuxC = ylo
6812  if Show_CBD.get() == 1 and len(VBuffMD)>4:
6813  if t < len(VBuffMD):
6814  ylo = VBuffMD[t] - CHBDOffset
6815  yhi = ylo
6816  n = t
6817  while n < (t + Tstep) and n < len(VBuffMD):
6818  v = VBuffMD[t] - CHBDOffset
6819  if v < ylo:
6820  ylo = v
6821  if v > yhi:
6822  yhi = v
6823  n = n + 1
6824  ylo = int(c2 - YconvMD * ylo)
6825  yhi = int(c2 - YconvMD * yhi)
6826  if (ylo < Ymin):
6827  ylo = Ymin
6828  if (ylo > Ymax):
6829  ylo = Ymax
6830  if (yhi < Ymin):
6831  yhi = Ymin
6832  if (yhi > Ymax):
6833  yhi = Ymax
6834  TMDVline.append(int(x1))
6835  TMDVline.append(int(ylo))
6836  TMDVline.append(int(x1))
6837  TMDVline.append(int(yhi))
6838  if (MouseX - X0L) > (x - Xstep) and (MouseX - X0L) < (x + Xstep):
6839  MouseMuxD = ylo
6840  if ( ShowC2_I.get() == 1 ):
6841  while n < (t + Tstep) and n < TRACEsize:
6842  i = IBuffB[t] - CHBIOffset
6843  if i < ilo:
6844  ilo = i
6845  if i > ihi:
6846  ihi = i
6847  n = n + 1
6848  ilo = int(c2 - YIconv2 * ilo)
6849  ihi = int(c2 - YIconv2 * ihi)
6850  if (ilo < Ymin):
6851  ilo = Ymin
6852  if (ilo > Ymax):
6853  ilo = Ymax
6854  if (ihi < Ymin):
6855  ihi = Ymin
6856  if (ihi > Ymax):
6857  ihi = Ymax
6858  T2Iline.append(int(x1))
6859  T2Iline.append(int(ilo))
6860  T2Iline.append(int(x1))
6861  T2Iline.append(int(ihi))
6862  if MathTrace.get() > 0:
6863  if MathTrace.get() == 1: # plot sum of CA-V and CB-V
6864  y1 = int(c1 - Yconv1 * (VBuffA[t] + VBuffB[t] - CHAOffset))
6865 
6866  elif MathTrace.get() == 2: # plot difference of CA-V and CB-V
6867  y1 = int(c1 - Yconv1 * (VBuffA[t] - VBuffB[t] - CHAOffset))
6868 
6869  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
6870  y1 = int(c2 - Yconv2 * (VBuffB[t] - VBuffA[t] - CHBOffset))
6871 
6872  elif MathTrace.get() == 4: # plot product of CA-V and CA-I
6873  Ypower = VBuffA[t] * IBuffA[t] # mAmps * Volts = mWatts
6874  ytemp = YIconv1 * (Ypower - CHAIOffset)
6875  y1 = int(c1 - ytemp)
6876 
6877  elif MathTrace.get() == 5: # plot product of CB-V and CB-I
6878  Ypower = VBuffB[t] * IBuffB[t] # mAmps * Volts = mWatts
6879  ytemp = YIconv2 * (Ypower - CHBIOffset)
6880  y1 = int(c2 - ytemp)
6881 
6882  elif MathTrace.get() == 6: # plot ratio of CA-V and CA-I
6883  Yohms = VBuffA[t] / (IBuffA[t] / 1000.0) # Volts / Amps = ohms
6884  ytemp = YIconv1 * (Yohms- CHAIOffset)
6885  y1 = int(c1 - ytemp)
6886 
6887  elif MathTrace.get() == 7: # plot ratio of CB-V and CB-I
6888  Yohms = VBuffB[t] / (IBuffB[t] / 1000.0) # Volts / Amps = ohms
6889  ytemp = YIconv2 * (Yohms - CHBIOffset)
6890  y1 = int(c2 - ytemp)
6891 
6892  elif MathTrace.get() == 8: # plot difference of CA-I and CB-I
6893  Ydif = (IBuffA[t] - IBuffB[t]) # in mA
6894  ytemp = YIconv1 * (Ydif - CHAIOffset)
6895  y1 = int(c2 - ytemp)
6896 
6897  elif MathTrace.get() == 9: # plot difference of CB-I and CA-I
6898  Ydif = (IBuffB[t] - IBuffA[t]) # in mA
6899  ytemp = YIconv2 * (Ydif - CHBIOffset)
6900  y1 = int(c2 - ytemp)
6901 
6902  elif MathTrace.get() == 10: # plot ratio of CB-V and CA-V
6903  try:
6904  y1 = int(c1 - Yconv2 * ((VBuffB[t] / VBuffA[t]) - CHBOffset)) # voltage gain A to B
6905  except:
6906  y1 = int(c1 - Yconv2 * ((VBuffB[t] / 0.000001) - CHBOffset))
6907  elif MathTrace.get() == 11: # plot ratio of CB-I and CA-I
6908  try:
6909  Y1 = (IBuffB[t] / IBuffA[t]) # current gain A to B
6910  except:
6911  Y1 = (IBuffB[t] / 0.000001)
6912  ytemp = YIconv2 * (Y1 - CHBIOffset)
6913  y1 = int(c2 - ytemp)
6914 
6915  elif MathTrace.get() == 12: # plot from equation string
6916  # MathString = "(VBuffA[t]+ VBuffB[t] - CHAOffset)"
6917  try:
6918  MathResult = eval(MathString)
6919  MathResult = MathResult - CHMOffset
6920  y1 = int(c1 - YconvM * MathResult)
6921  except:
6922  RUNstatus.set(0)
6923  x = GRW + 1
6924 
6925  if (y1 < Ymin):
6926  y1 = Ymin
6927  if (y1 > Ymax):
6928  y1 = Ymax
6929  if (ZOHold.get() == 1):
6930  Tmathline.append(int(x1))
6931  Tmathline.append(int(ypm))
6932  Tmathline.append(int(x1))
6933  Tmathline.append(int(y1))
6934  else:
6935  Tmathline.append(int(x1))
6936  Tmathline.append(int(y1))
6937  ypm = y1
6938  if Show_MathX.get() > 0:
6939  try:
6940  MathResult = eval(MathXString)
6941  MathResult = MathResult - CHMXOffset
6942  y1 = int(c1 - XconvMxy * MathResult)
6943  except:
6944  RUNstatus.set(0)
6945  x = GRW + 1
6946 
6947  if y1 < Ymin: # clip waveform if going off grid
6948  y1 = Ymin
6949  if y1 > Ymax:
6950  y1 = Ymax
6951  if ZOHold.get() == 1: # connet the dots with stair step
6952  TMXline.append(int(x1))
6953  TMXline.append(int(ypmx))
6954  TMXline.append(int(x1))
6955  TMXline.append(int(y1))
6956  else: # connet the dots with single line
6957  TMXline.append(int(x1))
6958  TMXline.append(int(y1))
6959  ypmx = y1
6960  if Show_MathY.get() > 0:
6961  try:
6962  MathResult = eval(MathYString)
6963  MathResult = MathResult - CHMYOffset
6964  y1 = int(c1 - YconvMxy * MathResult)
6965  except:
6966  RUNstatus.set(0)
6967  x = GRW + 1
6968 
6969  if y1 < Ymin: # clip waveform if going off grid
6970  y1 = Ymin
6971  if y1 > Ymax:
6972  y1 = Ymax
6973  if ZOHold.get() == 1: # connet the dots with stair step
6974  TMYline.append(int(x1))
6975  TMYline.append(int(ypmy))
6976  TMYline.append(int(x1))
6977  TMYline.append(int(y1))
6978  else: # connet the dots with single line
6979  TMYline.append(int(x1))
6980  TMYline.append(int(y1))
6981  ypmy = y1
6982  ft = ft + Tstep
6983  if (MouseX - X0L) == x: # > (x - 1) and (MouseX - X0L) < (x + 1):
6984  MouseCAV = ypv1
6985  MouseCAI = ypi1
6986  MouseCBV = ypv2
6987  MouseCBI = ypi2
6988  t = int(ft)
6989  if (t > len(VBuffA)):
6990  t = len(VBuffA)-2
6991  x = GRW
6992  x = x + Xstep
6993 
6994  # Make trigger triangle pointer
6995  Triggerline = [] # Trigger pointer
6996  Triggersymbol = [] # Trigger symbol
6997  if TgInput.get() > 0 or ChopTrig.get() > 0:
6998  if TgInput.get() == 1 or TgInput.get() == 5: # triggering on CA-V
6999  x1 = X0L
7000  ytemp = Yconv1 * (float(TRIGGERlevel)-CHAOffset) #
7001  y1 = int(c1 - ytemp)
7002  elif TgInput.get() == 2: # triggering on CA-I
7003  x1 = X0L+GRW
7004  y1 = int(c1 - YIconv1 * (float(TRIGGERlevel) - CHAIOffset))
7005  elif TgInput.get() == 3: # triggering on CB-V
7006  x1 = X0L
7007  ytemp = Yconv2 * (float(TRIGGERlevel)-CHBOffset) #
7008  y1 = int(c2 - ytemp)
7009  elif TgInput.get() == 4: # triggering on CB-I
7010  x1 = X0L+GRW
7011  y1 = int(c2 - YIconv2 * (float(TRIGGERlevel) - CHBIOffset))
7012  elif ChopTrig.get() == 1: # triggering on Mux A
7013  x1 = X0L
7014  ytemp = YconvMA * (float(TRIGGERlevel)-CHBAOffset) #
7015  y1 = int(c1 - ytemp)
7016  elif ChopTrig.get() == 2: # triggering on Mux B
7017  x1 = X0L
7018  ytemp = YconvMB * (float(TRIGGERlevel)-CHBBOffset) #
7019  y1 = int(c1 - ytemp)
7020  elif ChopTrig.get() == 3: # triggering on Mux A
7021  x1 = X0L
7022  ytemp = YconvMC * (float(TRIGGERlevel)-CHBCOffset) #
7023  y1 = int(c1 - ytemp)
7024  elif ChopTrig.get() == 4: # triggering on Mux A
7025  x1 = X0L
7026  ytemp = YconvMD * (float(TRIGGERlevel)-CHBDOffset) #
7027  y1 = int(c1 - ytemp)
7028  #
7029  if (y1 < Ymin):
7030  y1 = Ymin
7031  if (y1 > Ymax):
7032  y1 = Ymax
7033  Triggerline.append(int(x1-5))
7034  Triggerline.append(int(y1+5))
7035  Triggerline.append(int(x1+5))
7036  Triggerline.append(int(y1))
7037  Triggerline.append(int(x1-5))
7038  Triggerline.append(int(y1-5))
7039  Triggerline.append(int(x1-5))
7040  Triggerline.append(int(y1+5))
7041  x1 = X0L + (GRW/2)
7042  if TgEdge.get() == 0: # draw rising edge symbol
7043  y1 = -3
7044  y2 = -13
7045  else:
7046  y1 = -13
7047  y2 = -3
7048  Triggersymbol.append(int(x1-10))
7049  Triggersymbol.append(int(Ymin+y1))
7050  Triggersymbol.append(int(x1))
7051  Triggersymbol.append(int(Ymin+y1))
7052  Triggersymbol.append(int(x1))
7053  Triggersymbol.append(int(Ymin+y2))
7054  Triggersymbol.append(int(x1+10))
7055  Triggersymbol.append(int(Ymin+y2))
7056 
7058  global VBuffA, VBuffB, IBuffA, IBuffB
7059  global VmemoryA, VmemoryB, ImemoryA, ImemoryB
7060  global XYlineVA, XYlineVB, XYlineIA, XYlineIB, XYlineM, XYlineMX, XYlineMY
7061  global MathXString, MathYString, MathAxis, MathXAxis, MathYAxis
7062  global HoldOff, HoldOffentry
7063  global X0LXY, Y0TXY, GRWXY, GRHXY
7064  global YminXY, YmaxXY, XminXY, XmaxXY
7065  global SHOWsamples, ZOHold, AWGBMode
7066  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
7067  global TRACES, TRACESread, RUNstatus
7068  global Xsignal, YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
7069  global CHAsbxy, CHBsbxy, CHAOffset, CHBOffset, CHAIsbxy, CHBIsbxy, CHAIOffset, CHBIOffset
7070  global TMpdiv # Array with time / div values in ms
7071  global TMsb # Time per div spin box variable
7072  global TIMEdiv # current spin box value
7073  global SAMPLErate
7074  global SCstart, MathString
7075  global TRIGGERsample, TRACEsize, DX
7076  global TRIGGERlevel, TRIGGERentry, AutoLevel
7077  global InOffA, InGainA, InOffB, InGainB
7078  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2
7079  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2
7080  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7081  global CHAVPosEntryxy, CHAIPosEntryxy, CHAVPosEntryxy, CHBIPosEntryxy
7082  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
7083  global HozPoss, HozPossentry
7084 
7085  # Set the TRACEsize variable
7086  if len(VBuffA) < 100:
7087  return
7088  TRACEsize = SHOWsamples # Set the trace length
7089  SCstart = 0
7090  yloVA = yloVB = yloIA = yloIB = yloM = yloMX = yloMY = 0.0
7091  xlo = 0.0
7092  # get the vertical ranges
7093  try:
7094  CH1pdvRange = float(eval(CHAsbxy.get()))
7095  except:
7096  CHAsbxy.delete(0,END)
7097  CHAsbxy.insert(0, CH1pdvRange)
7098  try:
7099  CH2pdvRange = float(eval(CHBsbxy.get()))
7100  except:
7101  CHBsbxy.delete(0,END)
7102  CHBsbxy.insert(0, CH2pdvRange)
7103  try:
7104  CH1IpdvRange = float(eval(CHAIsbxy.get()))
7105  except:
7106  CHAIsbxy.delete(0,END)
7107  CHAIsbxy.insert(0, CH1IpdvRange)
7108  try:
7109  CH2IpdvRange = float(eval(CHBIsbxy.get()))
7110  except:
7111  CHBIsbxy.delete(0,END)
7112  CHBIsbxy.insert(0, CH2IpdvRange)
7113  # get the vertical offsets
7114  try:
7115  CHAOffset = float(eval(CHAVPosEntryxy.get()))
7116  except:
7117  CHAVPosEntryxy.delete(0,END)
7118  CHAVPosEntryxy.insert(0, CHAOffset)
7119  try:
7120  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
7121  except:
7122  CHAIPosEntryxy.delete(0,END)
7123  CHAIPosEntryxy.insert(0, CHAIOffset)
7124  try:
7125  CHBOffset = float(eval(CHBVPosEntryxy.get()))
7126  except:
7127  CHBVPosEntry.delete(0,END)
7128  CHBVPosEntry.insert(0, CHBOffset)
7129  try:
7130  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
7131  except:
7132  CHBIPosEntryxy.delete(0,END)
7133  CHBIPosEntryxy.insert(0, CHBIOffset)
7134  # prevent divide by zero error
7135  if CH1pdvRange < 0.001:
7136  CH1pdvRange = 0.001
7137  if CH2pdvRange < 0.001:
7138  CH2pdvRange = 0.001
7139  if CH1IpdvRange < 0.1:
7140  CH1IpdvRange = 0.1
7141  if CH2IpdvRange < 0.1:
7142  CH2IpdvRange = 0.1
7143  #
7144  Yconv1 = float(GRHXY/10.0) / CH1pdvRange # Vertical Conversion factors from samples to screen points
7145  Yconv2 = float(GRHXY/10.0) / CH2pdvRange
7146  YIconv1 = float(GRHXY/10.0) / CH1IpdvRange
7147  YIconv2 = float(GRHXY/10.0) / CH2IpdvRange
7148  Xconv1 = float(GRWXY/10.0) / CH1pdvRange # Horizontal Conversion factors from samples to screen points
7149  Xconv2 = float(GRWXY/10.0) / CH2pdvRange
7150  XIconv1 = float(GRWXY/10.0) / CH1IpdvRange
7151  XIconv2 = float(GRWXY/10.0) / CH2IpdvRange
7152 
7153  if MathAxis == "V-A":
7154  YconvM = Yconv1
7155  CHMOffset = CHAOffset
7156  elif MathAxis == "V-B":
7157  YconvM = Yconv2
7158  CHMOffset = CHBOffset
7159  elif MathAxis == "I-A":
7160  YconvM = YIconv1
7161  CHMOffset = CHAIOffset
7162  elif MathAxis == "I-B":
7163  YconvM = YIconv2
7164  CHMOffset = CHBIOffset
7165  else:
7166  YconvM = Yconv1
7167  CHMYOffset = CHAOffset
7168  if MathYAxis == "V-A":
7169  YconvMy = Yconv1
7170  CHMYOffset = CHAOffset
7171  elif MathYAxis == "V-B":
7172  YconvMy = Yconv2
7173  CHMYOffset = CHBOffset
7174  elif MathYAxis == "I-A":
7175  YconvMy = YIconv1
7176  CHMYOffset = CHAIOffset
7177  elif MathYAxis == "I-B":
7178  YconvMy = YIconv2
7179  CHMYOffset = CHBIOffset
7180  else:
7181  YconvMy = Yconv1
7182  CHMYOffset = CHAOffset
7183  if MathXAxis == "V-A":
7184  XconvMxy = Xconv1
7185  CHMXOffset = CHAOffset
7186  YconvMx = Yconv1
7187  elif MathXAxis == "V-B":
7188  XconvMxy = Xconv2
7189  CHMXOffset = CHBOffset
7190  YconvMx = Yconv2
7191  elif MathXAxis == "I-A":
7192  XconvMxy = XIconv1
7193  CHMXOffset = CHAIOffset
7194  YconvMx = YIconv1
7195  elif MathXAxis == "I-B":
7196  XconvMxy = XIconv2
7197  CHMXOffset = CHBIOffset
7198  YconvMx = YIconv2
7199  else:
7200  XconvMxy = Xconv1
7201  CHMXOffset = CHAOffset
7202  YconvMx = Yconv1
7203  # draw an X/Y plot
7204  XYlineVA = [] # XY Trace lines
7205  XYlineVB = []
7206  XYlineIA = []
7207  XYlineIB = []
7208  XYlineM = []
7209  XYlineMX = []
7210  XYlineMY = []
7211  t = int(TRIGGERsample) # skip over sampled before hold off time and trigger point
7212  c1 = GRHXY / 2.0 + Y0TXY # fixed correction channel A
7213  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
7214  while (t < TRACEsize):
7215  # calculate X axis points
7216  if Xsignal.get() == 1: # CVA
7217  xlo = VBuffA[t] - CHAOffset
7218  xlo = int(c2 + Xconv1 * xlo)
7219  elif Xsignal.get() == 3: # CVB
7220  xlo = VBuffB[t] - CHBOffset
7221  xlo = int(c2 + Xconv2 * xlo)
7222  elif Xsignal.get() == 2: # CAI
7223  xlo = (IBuffA[t]) - CHAIOffset
7224  xlo = int(c2 + XIconv1 * xlo)
7225  elif Xsignal.get() == 4: # CBI
7226  xlo = (IBuffB[t]) - CHBIOffset
7227  xlo = int(c2 + XIconv2 * xlo)
7228  elif Xsignal.get() == 5: # Math
7229  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7230  xlo = VBuffA[t] - VBuffB[t] - CHAOffset
7231  xlo = int(c2 + Xconv1 * xlo)
7232  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7233  xlo = VBuffB[t] - VBuffA[t] - CHBOffset
7234  xlo = int(c2 + Xconv2 * xlo)
7235  else:
7236  try:
7237  MathResult = eval(MathXString)
7238  MathResult = MathResult - CHMXOffset
7239  xlo = int(c2 + XconvMxy * MathResult)
7240  except:
7241  RUNstatus.set(0)
7242  if xlo < XminXY: # clip waveform if going off grid
7243  xlo = XminXY
7244  if xlo > XmaxXY:
7245  xlo = XmaxXY
7246  # calculate Y axis points
7247  if YsignalVA.get() == 1: # CAV
7248  yloVA = VBuffA[t] - CHAOffset
7249  yloVA = int(c1 - Yconv1 * yloVA)
7250  if yloVA < YminXY: # clip waveform if going off grid
7251  yloVA = YminXY
7252  if yloVA > YmaxXY:
7253  yloVA = YmaxXY
7254  XYlineVA.append(int(xlo))
7255  XYlineVA.append(int(yloVA))
7256  if YsignalVB.get() == 1: # CBV
7257  yloVB = VBuffB[t] - CHBOffset
7258  yloVB = int(c1 - Yconv2 * yloVB)
7259  if yloVB < YminXY: # clip waveform if going off grid
7260  yloVB = YminXY
7261  if yloVB > YmaxXY:
7262  yloVB = YmaxXY
7263  XYlineVB.append(int(xlo))
7264  XYlineVB.append(int(yloVB))
7265  if YsignalIB.get() == 1: # CBI
7266  yloIB = (IBuffB[t]) - CHBIOffset
7267  yloIB = int(c1 - YIconv2 * yloIB)
7268  if yloIB < YminXY: # clip waveform if going off grid
7269  yloIB = YminXY
7270  if yloIB > YmaxXY:
7271  yloIB = YmaxXY
7272  XYlineIB.append(int(xlo))
7273  XYlineIB.append(int(yloIB))
7274  if YsignalIA.get() == 1: # CAI
7275  yloIA = (IBuffA[t]) - CHAIOffset
7276  yloIA = int(c1 - YIconv1 * yloIA)
7277  if yloIA < YminXY: # clip waveform if going off grid
7278  yloIA = YminXY
7279  if yloIA > YmaxXY:
7280  yloIA = YmaxXY
7281  XYlineIA.append(int(xlo))
7282  XYlineIA.append(int(yloIA))
7283  if YsignalM.get() == 1: # Math
7284  if MathTrace.get() == 2: # plot difference of CA-V and CB-V
7285  yloM = VBuffA[t] - VBuffB[t] - CHAOffset
7286  yloM = int(c1 - Yconv1 * yloM)
7287  elif MathTrace.get() == 3: # plot difference of CB-V and CA-V
7288  yloM = VBuffB[t] - VBuffA[t] - CHBOffset
7289  yloM = int(c1 - Yconv2 * yloM)
7290  else:
7291  try:
7292  MathResult = eval(MathString)
7293  MathResult = MathResult - CHMOffset
7294  yloM = int(c1 - YconvM * MathResult)
7295  except:
7296  RUNstatus.set(0)
7297  if yloM < YminXY: # clip waveform if going off grid
7298  yloM = YminXY
7299  if yloM > YmaxXY:
7300  yloM = YmaxXY
7301  XYlineM.append(int(xlo))
7302  XYlineM.append(int(yloM))
7303  if YsignalMX.get() == 1: # Math-X
7304  try:
7305  MathResult = eval(MathXString)
7306  MathResult = MathResult - CHMXOffset
7307  yloMX = int(c1 - YconvMx * MathResult)
7308  except:
7309  RUNstatus.set(0)
7310  if yloMX < YminXY: # clip waveform if going off grid
7311  yloMX = YminXY
7312  if yloMX > YmaxXY:
7313  yloMX = YmaxXY
7314  XYlineMX.append(int(xlo))
7315  XYlineMX.append(int(yloMX))
7316  if YsignalMY.get() == 1: # Math-Y
7317  try:
7318  MathResult = eval(MathYString)
7319  MathResult = MathResult - CHMYOffset
7320  yloMY = int(c1 - YconvMy * MathResult)
7321  except:
7322  RUNstatus.set(0)
7323  if yloMY < YminXY: # clip waveform if going off grid
7324  yloMY = YminXY
7325  if yloMY > YmaxXY:
7326  yloMY = YmaxXY
7327  XYlineMY.append(int(xlo))
7328  XYlineMY.append(int(yloMY))
7329 
7330  t = int(t + 1)
7331 
7333  global T1Vline, T2Vline, T1Iline, T2Iline, TXYline # active trave lines
7334  global TMXline, TMYline
7335  global T1VRline, T2VRline, T1IRline, T2IRline # reference trace lines
7336  global D0line, D1line, D2line, D3line, D0, D1, D2, D3
7337  global Triggerline, Triggersymbol, Tmathline, TMRline, TXYRline
7338  global VBuffA, VBuffB, IBuffA, IBuffB
7339  global VBuffMA, VBuffMB, VBuffMC, VBuffMD, MuxScreenStatus, ChopMuxMode, ChopTrig
7340  global TMAVline, TMBVline, TMCVline, TMDVline, TMARline, TMBRline, TMCRline, TMDRline
7341  global VmemoryA, VmemoryB, VmemoryA, ImemoryB
7342  global X0L # Left top X value
7343  global Y0T # Left top Y value
7344  global GRW # Screenwidth
7345  global GRH # Screenheight
7346  global FontSize, EnableHSsampling, ETSDisp, MinigenScreenStatus
7347  global LabelPlotText, PlotLabelText # plot custom label text flag
7348  global MouseX, MouseY, MouseWidget, MouseCAV, MouseCAI, MouseCBV, MouseCBI
7349  global MouseMuxA, MouseMuxB, MouseMuxC, MouseMuxD
7350  global ShowXCur, ShowYCur, TCursor, VCursor
7351  global SHOWsamples # Number of samples in data record
7352  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, Show_MathX, Show_MathY
7353  global ShowRA_V, ShowRA_I, ShowRB_V, ShowRB_I, ShowMath
7354  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MathUnits, MathXUnits, MathYUnits
7355  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
7356  global Xsignal, Ysignal, MathTrace, MathAxis, MathXAxis, MathYAxis
7357  global RUNstatus, SingleShot, ManualTrigger, session # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
7358  global CHAsb # V range spinbox Index for channel 1
7359  global CHBsb # V range spinbox Index for channel 2
7360  global CHAOffset # Position value for channel 1 V
7361  global CHBOffset # Position value for channel 2 V
7362  global CHAIsb # I range spinbox Index for channel 1
7363  global CHBIsb # I range spinbox Index for channel 2
7364  global CHAIOffset # Postion value for channel 1 I
7365  global CHBIOffset # position value for channel 2 I
7366  global TMpdiv # Array with time / div values in ms
7367  global TMsb # Time per div spin box variable
7368  global TIMEdiv, Mulx, DISsamples # current spin box value
7369  global SAMPLErate, contloop, discontloop, HtMulEntry
7370  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry, TgInput
7371  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace7, COLORtraceR7 # The colors
7372  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6
7373  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6
7374  global CANVASwidth, CANVASheight
7375  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
7376  global ScreenTrefresh, SmoothCurves, Is_Triggered
7377  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
7378  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
7379  global InOffA, InGainA, InOffB, InGainB
7380  global CurOffA, CurOffB, CurGainA, CurGainB
7381  # Analog Mux channel measurement variables
7382  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
7383  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
7384  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
7385  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
7386  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
7387  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
7388  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
7389  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
7390  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
7391  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
7392  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
7393  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
7394  global AWGAShape, AWGBShape, MeasDiffAB, MeasDiffBA
7395  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
7396  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
7397  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
7398  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
7399  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
7400  global DacScreenStatus, DigScreenStatus, CHA_RC_HP, CHB_RC_HP
7401  global D0, D1, D2, D3, D4, D5, D6, D7
7402  global DevID, devx, MarkerNum, MarkerScale, MeasGateLeft, MeasGateRight, MeasGateStatus
7403  global HozPoss, HozPossentry, First_Slow_sweep, Roll_Mode
7404  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
7405  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
7406  global CHBADelayR1, CHBADelayR2, CHBADelayF, MeasDelay
7407  #
7408  Ymin = Y0T # Minimum position of time grid (top)
7409  Ymax = Y0T + GRH # Maximum position of time grid (bottom)
7410 
7411  # DISsamples = (10.0 * TIMEdiv) # grid width in time
7412  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
7413  # get the vertical ranges
7414  try:
7415  CH1pdvRange = float(eval(CHAsb.get()))
7416  except:
7417  CHAsb.delete(0,END)
7418  CHAsb.insert(0, CH1pdvRange)
7419  try:
7420  CH2pdvRange = float(eval(CHBsb.get()))
7421  except:
7422  CHBsb.delete(0,END)
7423  CHBsb.insert(0, CH2pdvRange)
7424  try:
7425  CH1IpdvRange = float(eval(CHAIsb.get()))
7426  except:
7427  CHAIsb.delete(0,END)
7428  CHAIsb.insert(0, CH1IpdvRange)
7429  try:
7430  CH2IpdvRange = float(eval(CHBIsb.get()))
7431  except:
7432  CHBIsb.delete(0,END)
7433  CHBIsb.insert(0, CH2IpdvRange)
7434  # get the vertical offsets
7435  try:
7436  CHAOffset = float(eval(CHAVPosEntry.get()))
7437  except:
7438  CHAVPosEntry.delete(0,END)
7439  CHAVPosEntry.insert(0, CHAOffset)
7440  try:
7441  CHAIOffset = float(eval(CHAIPosEntry.get()))
7442  except:
7443  CHAIPosEntry.delete(0,END)
7444  CHAIPosEntry.insert(0, CHAIOffset)
7445  try:
7446  CHBOffset = float(eval(CHBVPosEntry.get()))
7447  except:
7448  CHBVPosEntry.delete(0,END)
7449  CHBVPosEntry.insert(0, CHBOffset)
7450  try:
7451  CHBIOffset = float(eval(CHBIPosEntry.get()))
7452  except:
7453  CHBIPosEntry.delete(0,END)
7454  CHBIPosEntry.insert(0, CHBIOffset)
7455  try:
7456  HoldOff = float(eval(HoldOffentry.get()))
7457  if HoldOff < 0:
7458  HoldOff = 0
7459  except:
7460  HoldOffentry.delete(0,END)
7461  HoldOffentry.insert(0, HoldOff)
7462  if ETSDisp.get() > 0 or MinigenScreenStatus.get() > 0:
7463  try:
7464  Mulx = float(eval(HtMulEntry.get()))
7465  if Mulx < 1:
7466  Mulx = 1
7467  except:
7468  Mulx = 1
7469  if EnableHSsampling > 0:
7470  HtMulEntry.delete(0,END)
7471  HtMulEntry.insert(0, 1)
7472  else:
7473  Mulx = 1
7474  # slide trace left right by HozPoss
7475  try:
7476  HozPoss = float(eval(HozPossentry.get()))
7477  except:
7478  HozPossentry.delete(0,END)
7479  HozPossentry.insert(0, HozPoss)
7480  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
7481  try:
7482  CHMApdvRange = float(eval(CHB_Asb.get()))
7483  except:
7484  CHB_Asb.delete(0,END)
7485  CHB_Asb.insert(0, CHMApdvRange)
7486  try:
7487  CHMBpdvRange = float(eval(CHB_Bsb.get()))
7488  except:
7489  CHB_Bsb.delete(0,END)
7490  CHB_Bsb.insert(0, CHMBpdvRange)
7491  try:
7492  CHMCpdvRange = float(eval(CHB_Csb.get()))
7493  except:
7494  CHB_Csb.delete(0,END)
7495  CHB_Csb.insert(0, CHMCpdvRange)
7496  try:
7497  CHMDpdvRange = float(eval(CHB_Dsb.get()))
7498  except:
7499  CHB_Dsb.delete(0,END)
7500  CHB_Dsb.insert(0, CHMDpdvRange)
7501  if CHMApdvRange < 0.001:
7502  CHMApdvRange = 0.001
7503  if CHMBpdvRange < 0.001:
7504  CHMBpdvRange = 0.001
7505  if CHMCpdvRange < 0.001:
7506  CHMCpdvRange = 0.001
7507  if CHMDpdvRange < 0.001:
7508  CHMDpdvRange = 0.001
7509  try:
7510  CHBAOffset = float(eval(CHB_APosEntry.get()))
7511  except:
7512  CHB_APosEntry.delete(0,END)
7513  CHB_APosEntry.insert(0, CHBAOffset)
7514  try:
7515  CHBBOffset = float(eval(CHB_BPosEntry.get()))
7516  except:
7517  CHB_BPosEntry.delete(0,END)
7518  CHB_BPosEntry.insert(0, CHBBOffset)
7519  try:
7520  CHBCOffset = float(eval(CHB_CPosEntry.get()))
7521  except:
7522  CHB_CPosEntry.delete(0,END)
7523  CHB_CPosEntry.insert(0, CHBCOffset)
7524  try:
7525  CHBDOffset = float(eval(CHB_DPosEntry.get()))
7526  except:
7527  CHB_DPosEntry.delete(0,END)
7528  CHB_DPosEntry.insert(0, CHBDOffset)
7529  # prevent divide by zero error
7530  if CH1pdvRange < 0.001:
7531  CH1pdvRange = 0.001
7532  if CH2pdvRange < 0.001:
7533  CH2pdvRange = 0.001
7534  if CH1IpdvRange < 0.1:
7535  CH1IpdvRange = 0.1
7536  if CH2IpdvRange < 0.1:
7537  CH2IpdvRange = 0.1
7538  vt = HoldOff + HozPoss # invert sign and scale to mSec
7539  if ScreenTrefresh.get() == 0:
7540  # Delete all items on the screen
7541  ca.delete(ALL) # remove all items
7542  MarkerNum = 0
7543  # Draw horizontal grid lines
7544  i = 0
7545  x1 = X0L
7546  x2 = X0L + GRW
7547  mg_siz = GRW/10.0
7548  mg_inc = mg_siz/5.0
7549  MathFlag1 = (MathAxis == "V-A" and MathTrace.get() == 12) or (MathXAxis == "V-A" and Show_MathX.get() == 1) or (MathYAxis == "V-A" and Show_MathY.get() == 1)
7550  MathFlag2 = (MathAxis == "V-B" and MathTrace.get() == 12) or (MathXAxis == "V-B" and Show_MathX.get() == 1) or (MathYAxis == "V-B" and Show_MathY.get() == 1)
7551  MathFlag3 = (MathAxis == "I-A" and MathTrace.get() == 12) or (MathXAxis == "I-A" and Show_MathX.get() == 1) or (MathYAxis == "I-A" and Show_MathY.get() == 1)
7552  MathFlag4 = (MathAxis == "I-B" and MathTrace.get() == 12) or (MathXAxis == "I-B" and Show_MathX.get() == 1) or (MathYAxis == "I-B" and Show_MathY.get() == 1)
7553  # vertical scale text labels
7554  RightOffset = FontSize * 3
7555  LeftOffset = int(FontSize/2)
7556  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
7557  ca.create_text(x1-LeftOffset, 12, text="CA-V", fill=COLORtrace1, anchor="e", font=("arial", FontSize-1 ))
7558  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
7559  ca.create_text(x2+LeftOffset, 12, text="CA-I", fill=COLORtrace3, anchor="w", font=("arial", FontSize-1 ))
7560  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
7561  ca.create_text(x1-RightOffset+2, 12, text="CB-V", fill=COLORtrace2, anchor="e", font=("arial", FontSize-1 )) #26
7562  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
7563  ca.create_text(x2+RightOffset+4, 12, text="CB-I", fill=COLORtrace4, anchor="w", font=("arial", FontSize-1 )) #28
7564  #
7565  while (i < 11):
7566  y = Y0T + i * GRH/10.0
7567  Dline = [x1,y,x2,y]
7568  if i == 5:
7569  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
7570  k = 0
7571  while (k < 10):
7572  l = 1
7573  while (l < 5):
7574  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
7575  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7576  l = l + 1
7577  k = k + 1
7578  else:
7579  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7580 
7581  if (ShowC1_V.get() == 1 or MathTrace.get() == 1 or MathTrace.get() == 2 or MathFlag1):
7582  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
7583  # Vaxis_label = ' {0:.2f} '.format(Vaxis_value)
7584  Vaxis_label = str(round(Vaxis_value,3 ))
7585  ca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
7586 
7587  if (ShowC1_I.get() == 1 or MathTrace.get() == 4 or MathTrace.get() == 6 or MathTrace.get() == 8 or MathFlag3):
7588  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
7589  Iaxis_label = str(round(Iaxis_value, 3))
7590  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
7591 
7592  if (ShowC2_V.get() == 1 or MathTrace.get() == 3 or MathTrace.get() == 10 or MathFlag2):
7593  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
7594  Vaxis_label = str(round(Vaxis_value, 3))
7595  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
7596 
7597  if (ShowC2_I.get() == 1 or MathTrace.get() == 5 or MathTrace.get() == 7 or MathTrace.get() == 9 or MathTrace.get() == 11 or MathFlag4):
7598  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
7599  Iaxis_label = str(round(Iaxis_value, 3))
7600  ca.create_text(x2+RightOffset+4, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 28
7601  if MuxScreenStatus.get() == 1:
7602  if Show_CBA.get() == 1:
7603  Vaxis_value = (((5-i) * CHMApdvRange ) + CHBAOffset)
7604  Vaxis_label = str(round(Vaxis_value, 3))
7605  ca.create_text(x1-RightOffset+2, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize )) # 26
7606  if Show_CBB.get() == 1:
7607  Iaxis_value = 1.0 * (((5-i) * CHMBpdvRange ) + CHBBOffset)
7608  Iaxis_label = str(round(Iaxis_value, 3))
7609  ca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace6, anchor="w", font=("arial", FontSize ))
7610  if Show_CBC.get() == 1:
7611  Iaxis_value = 1.0 * (((5-i) * CHMCpdvRange ) + CHBCOffset)
7612  Iaxis_label = str(round(Iaxis_value, 3))
7613  ca.create_text(x2+RightOffset-3, y, text=Iaxis_label, fill=COLORtrace7, anchor="w", font=("arial", FontSize )) # 21
7614  if Show_CBD.get() == 1:
7615  Iaxis_value = 1.0 * (((5-i) * CHMDpdvRange ) + CHBDOffset)
7616  Iaxis_label = str(round(Iaxis_value, 3))
7617  ca.create_text(x2+RightOffset+10, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize )) # 38
7618  i = i + 1
7619  # Draw vertical grid lines
7620  i = 0
7621  y1 = Y0T
7622  y2 = Y0T + GRH
7623  mg_siz = GRH/10.0
7624  mg_inc = mg_siz/5.0
7625  vx = TIMEdiv/Mulx
7626  vt = HoldOff/Mulx # invert sign and scale to mSec
7627  # vx = TIMEdiv
7628  while (i < 11):
7629  x = X0L + i * GRW/10.0
7630  Dline = [x,y1,x,y2]
7631  if (i == 5):
7632  ca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
7633  k = 0
7634  while (k < 10):
7635  l = 1
7636  while (l < 5):
7637  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
7638  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7639  l = l + 1
7640  k = k + 1
7641  #
7642  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7643  if vx >= 1000:
7644  axis_value = ((i * vx)+ vt) / 1000.0
7645  axis_label = ' {0:.1f} '.format(axis_value) + " S"
7646  if vx < 1000 and vx >= 1:
7647  axis_value = (i * vx) + vt
7648  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
7649  if vx < 1:
7650  axis_value = ((i * vx) + vt) * 1000.0
7651  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
7652  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
7653  else:
7654  ca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
7655  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7656  if vx >= 1000:
7657  axis_value = ((i * vx)+ vt) / 1000.0
7658  axis_label = ' {0:.1f} '.format(axis_value) + " S"
7659  if vx < 1000 and vx >= 1:
7660  axis_value = (i * vx) + vt
7661  axis_label = ' {0:.1f} '.format(axis_value) + " mS"
7662  if vx < 1:
7663  axis_value = ((i * vx) + vt) * 1000.0
7664  axis_label = ' {0:.1f} '.format(axis_value) + " uS"
7665  ca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
7666 
7667  i = i + 1
7668  # Write the trigger line if available
7669  if Roll_Mode.get() == 0: # Don't show trigger indicator when in Roll Mode
7670  if len(Triggerline) > 2: # Avoid writing lines with 1 coordinate
7671  ca.create_polygon(Triggerline, outline=COLORtrigger, fill=COLORtrigger, width=1)
7672  ca.create_line(Triggersymbol, fill=COLORtrigger, width=GridWidth.get())
7673  if TgInput.get() == 1:
7674  TgLabel = "CA-V"
7675  if TgInput.get() == 2:
7676  TgLabel = "CA-I"
7677  if TgInput.get() == 3:
7678  TgLabel = "CB-V"
7679  if TgInput.get() == 4:
7680  TgLabel = "CB-I"
7681  if TgInput.get() == 5:
7682  TgLabel = "VA or VB"
7683  if TgInput.get() == 6:
7684  TgLabel = "Alternate"
7685  if ChopTrig.get() == 1:
7686  TgLabel = "Mux A"
7687  if ChopTrig.get() == 2:
7688  TgLabel = "Mux B"
7689  if ChopTrig.get() == 3:
7690  TgLabel = "Mux C"
7691  if ChopTrig.get() == 4:
7692  TgLabel = "Mux D"
7693  if Is_Triggered == 1:
7694  TgLabel = TgLabel + " Triggered"
7695  else:
7696  TgLabel = TgLabel + " Not Triggered"
7697  if SingleShot.get() > 0:
7698  TgLabel = TgLabel + " Armed"
7699  x = X0L + (GRW/2) + 12
7700  ca.create_text(x, Ymin-FontSize, text=TgLabel, fill=COLORtrigger, anchor="w", font=("arial", FontSize ))
7701  # Draw T - V Cursor lines if required
7702  if MarkerScale.get() == 0:
7703  Yconv1 = float(GRH/10.0) / CH1pdvRange
7704  Yoffset1 = CHAOffset
7705  COLORmarker = COLORtrace1
7706  Units = " V"
7707  if MarkerScale.get() == 1:
7708  MouseY = MouseCAV
7709  Yconv1 = float(GRH/10.0) / CH1pdvRange
7710  Yoffset1 = CHAOffset
7711  COLORmarker = COLORtrace1
7712  Units = " V"
7713  if MarkerScale.get() == 2:
7714  MouseY = MouseCBV
7715  Yconv1 = float(GRH/10.0) / CH2pdvRange
7716  Yoffset1 = CHBOffset
7717  COLORmarker = COLORtrace2
7718  Units = " V"
7719  if MarkerScale.get() == 3:
7720  MouseY = MouseCAI
7721  Yconv1 = float(GRH/10.0) / CH1IpdvRange
7722  Yoffset1 = CHAIOffset
7723  COLORmarker = COLORtrace3
7724  Units = " mA"
7725  if MarkerScale.get() == 4:
7726  MouseY = MouseCBI
7727  Yconv1 = float(GRH/10.0) / CH2IpdvRange
7728  Yoffset1 = CHBIOffset
7729  COLORmarker = COLORtrace4
7730  Units = " mA"
7731  # Analog Mux settings
7732  if MarkerScale.get() == 5:
7733  MouseY = MouseMuxA
7734  Yconv1 = float(GRH/10.0) / CHMApdvRange
7735  Yoffset1 = CHBAOffset
7736  COLORmarker = COLORtrace2
7737  Units = " V"
7738  if MarkerScale.get() == 6:
7739  MouseY = MouseMuxB
7740  Yconv1 = float(GRH/10.0) / CHMBpdvRange
7741  Yoffset1 = CHBBOffset
7742  COLORmarker = COLORtrace6
7743  Units = " V"
7744  if MarkerScale.get() == 7:
7745  MouseY = MouseMuxC
7746  Yconv1 = float(GRH/10.0) / CHMCpdvRange
7747  Yoffset1 = CHBCOffset
7748  COLORmarker = COLORtrace7
7749  Units = " V"
7750  if MarkerScale.get() == 8:
7751  MouseY = MouseMuxD
7752  Yconv1 = float(GRH/10.0) / CHMDpdvRange
7753  Yoffset1 = CHBDOffset
7754  COLORmarker = COLORtrace4
7755  Units = " V"
7756 #
7757  if ShowTCur.get() > 0:
7758  Dline = [TCursor, Y0T, TCursor, Y0T+GRH]
7759  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7760  Tpoint = ((TCursor-X0L) * Tstep) + vt
7761  Tpoint = Tpoint/Mulx
7762  if Tpoint >= 1000:
7763  axis_value = Tpoint / 1000.0
7764  V_label = ' {0:.2f} '.format(axis_value) + " S"
7765  if Tpoint < 1000 and Tpoint >= 1:
7766  axis_value = Tpoint
7767  V_label = ' {0:.2f} '.format(axis_value) + " mS"
7768  if Tpoint < 1:
7769  axis_value = Tpoint * 1000.0
7770  V_label = ' {0:.2f} '.format(axis_value) + " uS"
7771  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7772  ca.create_text(TCursor, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
7773  if ShowVCur.get() > 0:
7774  Dline = [X0L, VCursor, X0L+GRW, VCursor]
7775  ca.create_line(Dline, dash=(4,3), fill=COLORmarker, width=GridWidth.get())
7776  c1 = GRH / 2 + Y0T # fixed Y correction
7777  yvolts = ((VCursor-c1)/Yconv1) - Yoffset1
7778  V1String = ' {0:.3f} '.format(-yvolts)
7779  V_label = V1String + Units
7780  ca.create_text(X0L+GRW+2, VCursor, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
7781  if ShowTCur.get() == 0 and ShowVCur.get() == 0 and MouseWidget == ca:
7782  if MouseX > X0L and MouseX < X0L+GRW and MouseY > Y0T and MouseY < Y0T+GRH:
7783  Dline = [MouseX, Y0T, MouseX, Y0T+GRH]
7784  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7785  ca.create_oval(MouseX-GridWidth.get(), MouseY-GridWidth.get(), MouseX+GridWidth.get(), MouseY+GridWidth.get(), outline=COLORtrigger, fill=COLORtrigger, width=GridWidth.get())
7786  Tpoint = ((MouseX-X0L) * Tstep) + vt
7787  Tpoint = Tpoint/Mulx
7788  if Tpoint >= 1000:
7789  axis_value = Tpoint / 1000.0
7790  V_label = ' {0:.2f} '.format(axis_value) + " S"
7791  if Tpoint < 1000 and Tpoint >= 1:
7792  axis_value = Tpoint
7793  V_label = ' {0:.2f} '.format(axis_value) + " mS"
7794  if Tpoint < 1:
7795  axis_value = Tpoint * 1000.0
7796  V_label = ' {0:.2f} '.format(axis_value) + " uS"
7797  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7798  ca.create_text(MouseX, Y0T+GRH+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
7799  Dline = [X0L, MouseY, X0L+GRW, MouseY]
7800  ca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
7801  c1 = GRH / 2 + Y0T # fixed Y correction
7802  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
7803  V1String = ' {0:.3f} '.format(-yvolts)
7804  V_label = V1String + Units
7805  ca.create_text(X0L+GRW+2, MouseY, text=V_label, fill=COLORmarker, anchor="w", font=("arial", FontSize ))
7806 #
7807  if MeasGateStatus.get() == 1:
7808  LeftGate = X0L + MeasGateLeft / Tstep
7809  RightGate = X0L + MeasGateRight / Tstep
7810  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace5)
7811  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, dash=(5,3), width=GridWidth.get(), fill=COLORtrace7)
7812  #
7813  # TString = ' {0:.2f} '.format(Tpoint)
7814  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
7815  DT = (MeasGateRight-MeasGateLeft)/Mulx
7816  if DT == 0.0:
7817  DT = 1.0
7818  if DT >= 1000:
7819  axis_value = DT / 1000.0
7820  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
7821  if DT < 1000 and DT >= 1:
7822  axis_value = DT
7823  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
7824  if DT < 1:
7825  axis_value = DT * 1000.0
7826  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
7827  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
7828  DFreq = ' {0:.3f} '.format(1.0/DT)
7829  V_label = " Delta T" + DeltaT
7830  #V_label = V_label + Units
7831  V_label = V_label + ", Freq " + DFreq + " KHz"
7832  # place in upper left unless specified otherwise
7833  x = X0L + 5
7834  y = Y0T + 7
7835  Justify = 'w'
7836  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
7837  x = X0L + GRW - 5
7838  y = Y0T + 7
7839  Justify = 'e'
7840  if MarkerLoc == 'LL' or MarkerLoc == 'll':
7841  x = X0L + 5
7842  y = Y0T + GRH + 7 - (MarkerNum*10)
7843  Justify = 'w'
7844  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
7845  x = X0L + GRW - 5
7846  y = Y0T + GRH + 7
7847  Justify = 'e'
7848  ca.create_text(x, y, text=V_label, fill=COLORtrace5, anchor=Justify, font=("arial", FontSize ))
7849  #
7850 #
7851  SmoothBool = SmoothCurves.get()
7852  # Write the traces if available
7853  if len(T1Vline) > 4: # Avoid writing lines with 1 coordinate
7854  ca.create_line(T1Vline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the voltage trace 1
7855  if len(T1Iline) > 4: # Avoid writing lines with 1 coordinate
7856  ca.create_line(T1Iline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get()) # Write the current trace 1
7857  if len(T2Vline) > 4: # Write the trace 2 if active
7858  ca.create_line(T2Vline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7859  if len(T2Iline) > 4:
7860  ca.create_line(T2Iline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7861  if len(Tmathline) > 4 and MathTrace.get() > 0: # Write Math tace if active
7862  ca.create_line(Tmathline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7863  if len(TMXline) > 4 : # Write X Math tace if active
7864  ca.create_line(TMXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7865  if len(TMYline) > 4 : # Write Y Math tace if active
7866  ca.create_line(TMYline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7867  if MuxScreenStatus.get() == 1:
7868  if len(TMAVline) > 4: # Avoid writing lines with 1 coordinate
7869  ca.create_line(TMAVline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7870  if len(TMBVline) > 4: # Avoid writing lines with 1 coordinate
7871  ca.create_line(TMBVline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7872  if len(TMCVline) > 4: # Avoid writing lines with 1 coordinate
7873  ca.create_line(TMCVline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7874  if len(TMDVline) > 4: # Avoid writing lines with 1 coordinate
7875  ca.create_line(TMDVline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7876  if ShowRMA.get() == 1 and len(TMARline) > 4:
7877  ca.create_line(TMARline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7878  if ShowRMB.get() == 1 and len(TMBRline) > 4:
7879  ca.create_line(TMBRline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7880  if ShowRMC.get() == 1 and len(TMCRline) > 4:
7881  ca.create_line(TMCRline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7882  if ShowRMD.get() == 1 and len(TMDRline) > 4:
7883  ca.create_line(TMDRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7884  if ShowRA_V.get() == 1 and len(T1VRline) > 4:
7885  ca.create_line(T1VRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7886  if ShowRA_I.get() == 1 and len(T1IRline) > 4:
7887  ca.create_line(T1IRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7888  if ShowRB_V.get() == 1 and len(T2VRline) > 4:
7889  ca.create_line(T2VRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7890  if ShowRB_I.get() == 1 and len(T2IRline) > 4:
7891  ca.create_line(T2IRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7892  if ShowMath.get() == 1 and len(TMRline) > 4:
7893  ca.create_line(TMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7894  if First_Slow_sweep == 1:
7895  # print(len(D0line),len(D1line), len(D2line), len(D3line))
7896  if D0.get() == 0:
7897  ca.create_line(D0line, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7898  if D1.get() == 0:
7899  ca.create_line(D1line, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7900  if D2.get() == 0:
7901  ca.create_line(D2line, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7902  if D3.get() == 0:
7903  ca.create_line(D3line, fill=COLORzeroline, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
7904  # General information on top of the grid
7905  # Sweep information
7906  if session.continuous:
7907  sttxt = "Running Continuous"
7908  else:
7909  sttxt = "Running Discontinuous"
7910  if TRACEmodeTime.get() == 1:
7911  sttxt = sttxt + " Averaging"
7912  if ManualTrigger.get() == 1:
7913  sttxt = "Manual Trigger"
7914  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
7915  sttxt = "Stopped"
7916  if ScreenTrefresh.get() == 1:
7917  sttxt = sttxt + " Persistance ON"
7918  # Delete text at bottom of screen
7919  de = ca.find_enclosed( X0L-1, Y0T+GRH+12, CANVASwidth, Y0T+GRH+100)
7920  for n in de:
7921  ca.delete(n)
7922  # Delete text at top of screen
7923  de = ca.find_enclosed( X0L-1, -1, CANVASwidth, 20)
7924  for n in de:
7925  ca.delete(n)
7926  if Roll_Mode.get() == 0:
7927  if LabelPlotText.get() > 0:
7928  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7929  else:
7930  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
7931  else:
7932  if LabelPlotText.get() > 0:
7933  txt = PlotLabelText + " Rolling Sweep " + sttxt
7934  else:
7935  txt = "Device ID " + DevID[17:31] + " Rolling Sweep " + sttxt
7936  x = X0L+2
7937  y = 12
7938  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
7939  # digital I/O indicators
7940  x2 = X0L + GRW
7941  BoxColor = "#808080" # gray
7942  if DacScreenStatus.get() == 0 and (DigScreenStatus.get() == 1 or MuxScreenStatus.get() == 1):
7943  if D0.get() == 0 and D4.get() == 0:
7944  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
7945  if Dval[0] == 1:
7946  BoxColor = "#00ff00" # 100% green
7947  elif Dval[0] == 0:
7948  BoxColor = "#ff0000" # 100% red
7949  ca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
7950  else:
7951  ca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
7952  if D1.get() == 0 and D5.get() == 0:
7953  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
7954  if Dval[0] == 1:
7955  BoxColor = "#00ff00" # 100% green
7956  elif Dval[0] == 0:
7957  BoxColor = "#ff0000" # 100% red
7958  ca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
7959  else:
7960  ca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
7961  if D2.get() == 0 and D6.get() == 0:
7962  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
7963  if Dval[0] == 1:
7964  BoxColor = "#00ff00" # 100% green
7965  elif Dval[0] == 0:
7966  BoxColor = "#ff0000" # 100% red
7967  ca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
7968  else:
7969  ca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
7970  if D3.get() == 0 and D7.get() == 0:
7971  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
7972  if Dval[0] == 1:
7973  BoxColor = "#00ff00" # 100% green
7974  elif Dval[0] == 0:
7975  BoxColor = "#ff0000" # 100% red
7976  ca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
7977  else:
7978  ca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
7979  ca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
7980  # Time sweep information and view at information
7981  vx = TIMEdiv/Mulx
7982  if vx >= 1000:
7983  txt = ' {0:.2f} '.format(vx / 1000.0) + " S/div"
7984  if vx < 1000 and vx >= 1:
7985  txt = ' {0:.2f} '.format(vx) + " mS/div"
7986  if vx < 1:
7987  txt = ' {0:.2f} '.format(vx * 1000.0) + " uS/div"
7988 
7989  txt = txt + " "
7990  #
7991  txt = txt + "View at "
7992  if abs(vt) >= 1000:
7993  txt = txt + str(int(vt / 1000.0)) + " S "
7994  if abs(vt) < 1000 and abs(vt) >= 1:
7995  txt = txt + str(int(vt)) + " mS "
7996  if abs(vt) < 1:
7997  txt = txt + str(int(vt * 1000.0)) + " uS "
7998  # print period and frequency of displayed channels
7999  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
8000  if ETSDisp.get() > 0:
8001  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
8002  else:
8003  if MeasGateStatus.get() == 1:
8004  if (MeasGateRight-MeasGateLeft) > 0:
8005  hldn = int(MeasGateLeft * SAMPLErate/1000) + TRIGGERsample
8006  Endsample = int(MeasGateRight * SAMPLErate/1000) + TRIGGERsample
8007  if Endsample <= hldn:
8008  Endsample = hldn + 2
8009  FindRisingEdge(VBuffA[hldn:Endsample],VBuffB[hldn:Endsample])
8010  else:
8011  FindRisingEdge(VBuffA,VBuffB)
8012  if ShowC1_V.get() == 1:
8013  if MeasAHW.get() == 1:
8014  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
8015  if MeasALW.get() == 1:
8016  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
8017  if MeasADCy.get() == 1:
8018  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8019  if MeasAPER.get() == 1:
8020  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
8021  if MeasAFREQ.get() == 1:
8022  txt = txt + " CA Freq = "
8023  ChaF = CHAfreq*Mulx
8024  if ChaF < 1000:
8025  V1String = ' {0:.1f} '.format(ChaF)
8026  txt = txt + str(V1String) + " Hz "
8027  if ChaF > 1000 and ChaF < 1000000:
8028  V1String = ' {0:.1f} '.format(ChaF/1000)
8029  txt = txt + str(V1String) + " KHz "
8030  if ChaF > 1000000:
8031  V1String = ' {0:.1f} '.format(ChaF/1000000)
8032  txt = txt + str(V1String) + " MHz "
8033  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8034  if ShowC2_V.get() == 1:
8035  if MeasBHW.get() == 1:
8036  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
8037  if MeasBLW.get() == 1:
8038  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
8039  if MeasBDCy.get() == 1:
8040  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8041  if MeasBPER.get() == 1:
8042  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
8043  if MeasBFREQ.get() == 1:
8044  txt = txt + " CB Freq = "
8045  ChaF = CHBfreq*Mulx
8046  if ChaF < 1000:
8047  V1String = ' {0:.1f} '.format(ChaF)
8048  txt = txt + str(V1String) + " Hz "
8049  if ChaF > 1000 and ChaF < 1000000:
8050  V1String = ' {0:.1f} '.format(ChaF/1000)
8051  txt = txt + str(V1String) + " KHz "
8052  if ChaF > 1000000:
8053  V1String = ' {0:.1f} '.format(ChaF/1000000)
8054  txt = txt + str(V1String) + " MHz "
8055  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8056  if MuxScreenStatus.get() == 0:
8057  if MeasPhase.get() == 1:
8058  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8059  if MeasDelay.get() == 1:
8060  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8061 
8062  x = X0L
8063  y = Y0T+GRH+int(2.5 *FontSize) # 20
8064  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8065  if MeasTopV1.get() == 1 or MeasBaseV1.get() == 1 or MeasTopV2.get() == 1 or MeasBaseV2.get() == 1:
8066  MakeHistogram()
8067  txt = " "
8068  if ShowC1_V.get() == 1:
8069  # Channel A information
8070  if CHA_RC_HP.get() == 1:
8071  txt = "CHA: HP "
8072  else:
8073  txt = "CHA: "
8074  txt = txt + str(CH1pdvRange) + " V/div"
8075  if MeasDCV1.get() == 1:
8076  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8077  if MeasMaxV1.get() == 1:
8078  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8079  if MeasTopV1.get() == 1:
8080  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8081  if MeasMinV1.get() == 1:
8082  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8083  if MeasBaseV1.get() == 1:
8084  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
8085  if MeasMidV1.get() == 1:
8086  MidV1 = (MaxV1+MinV1)/2.0
8087  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8088  if MeasPPV1.get() == 1:
8089  PPV1 = MaxV1-MinV1
8090  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8091  if MeasRMSV1.get() == 1:
8092  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8093  if MeasRMSVA_B.get() == 1:
8094  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
8095  if MeasDiffAB.get() == 1:
8096  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
8097  if MeasUserA.get() == 1:
8098  try:
8099  TempValue = eval(UserAString)
8100  V1String = ' {0:.4f} '.format(TempValue)
8101  except:
8102  V1String = "####"
8103  txt = txt + UserALabel + " = " + V1String
8104  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
8105  txt = "CHA: "
8106  txt = txt + str(CH1IpdvRange) + " mA/div"
8107  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
8108  txt = txt + "CHA: "
8109  txt = txt + str(CH1IpdvRange) + " mA/div"
8110  if ShowC1_I.get() == 1:
8111  if MeasDCI1.get() == 1:
8112  V1String = ' {0:.2f} '.format(DCI1)
8113  txt = txt + " AvgI = " + V1String
8114  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8115  try:
8116  Resvalue = (DCV1/DCI1)*1000
8117  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8118  except:
8119  txt = txt + " Res = OverRange"
8120  if MeasMaxI1.get() == 1:
8121  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8122  if MeasMinI1.get() == 1:
8123  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8124  if MeasMidI1.get() == 1:
8125  MidI1 = (MaxI1+MinI1)/2.0
8126  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8127  if MeasPPI1.get() == 1:
8128  PPI1 = MaxI1-MinI1
8129  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8130  if MeasRMSI1.get() == 1:
8131  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
8132 
8133  x = X0L
8134  y = Y0T+GRH+(4*FontSize) # 32
8135  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8136  txt= " "
8137  # Channel B information
8138  if MuxScreenStatus.get() == 1:
8139  txt = "CHB-Mux: "
8140  if Show_CBA.get() > 0:
8141  FindRisingEdge(VBuffA,VBuffMA)
8142  elif Show_CBB.get() > 0:
8143  FindRisingEdge(VBuffA,VBuffMB)
8144  elif Show_CBC.get() > 0:
8145  FindRisingEdge(VBuffA,VBuffMC)
8146  elif Show_CBD.get() > 0:
8147  FindRisingEdge(VBuffA,VBuffMD)
8148  if MeasPhase.get() == 1:
8149  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8150  if MeasDelay.get() == 1:
8151  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
8152  if MeasUserB.get() == 1:
8153  try:
8154  TempValue = eval(UserBString)
8155  V1String = ' {0:.4f} '.format(TempValue)
8156  except:
8157  V1String = "####"
8158  txt = txt + UserBLabel + " = " + V1String
8159  if ShowC2_V.get() == 1:
8160  if CHB_RC_HP.get() == 1:
8161  txt = "CHB: HP "
8162  else:
8163  txt = "CHB: "
8164  txt = txt + str(CH2pdvRange) + " V/div"
8165  if MeasDCV2.get() == 1:
8166  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8167  if MeasMaxV2.get() == 1:
8168  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8169  if MeasTopV2.get() == 1:
8170  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8171  if MeasMinV2.get() == 1:
8172  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8173  if MeasBaseV2.get() == 1:
8174  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
8175  if MeasMidV2.get() == 1:
8176  MidV2 = (MaxV2+MinV2)/2.0
8177  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8178  if MeasPPV2.get() == 1:
8179  PPV2 = MaxV2-MinV2
8180  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
8181  if MeasRMSV2.get() == 1:
8182  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
8183  if MeasDiffBA.get() == 1:
8184  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
8185  if MeasUserB.get() == 1:
8186  try:
8187  TempValue = eval(UserBString)
8188  V1String = ' {0:.4f} '.format(TempValue)
8189  except:
8190  V1String = "####"
8191  txt = txt + UserBLabel + " = " + V1String
8192  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
8193  txt = "CHB: "
8194  txt = txt + str(CH2IpdvRange) + " mA/div"
8195  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
8196  txt = txt + "CHB: "
8197  txt = txt + str(CH2IpdvRange) + " mA/div"
8198  if ShowC2_I.get() == 1:
8199  if MeasDCI2.get() == 1:
8200  V1String = ' {0:.2f} '.format(DCI2)
8201  txt = txt + " AvgI = " + V1String
8202  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
8203  try:
8204  Resvalue = (DCV2/DCI2)*1000
8205  R1String = ' {0:.1f} '.format(Resvalue)
8206  txt = txt + " Res = " + R1String
8207  except:
8208  txt = txt + " Res = OverRange"
8209  if MeasMaxI2.get() == 1:
8210  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
8211  if MeasMinI2.get() == 1:
8212  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
8213  if MeasMidI2.get() == 1:
8214  MidI2 = (MaxI2+MinI2)/2.0
8215  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
8216  if MeasPPI2.get() == 1:
8217  PPI2 = MaxI2-MinI2
8218  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
8219  if MeasRMSI2.get() == 1:
8220  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
8221 
8222  x = X0L
8223  y = Y0T+GRH+int(5.5*FontSize) # 44
8224  ca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8225 
8227  global XYlineVA, XYlineIA, XYlineVB, XYlineIB, XYlineM, XYlineMX, XYlineMY # active trave lines
8228  global Tmathline, TMRline, XYRlineVA, XYRlineIA, XYRlineVB, XYRlineIB, XYRlineM, XYRlineMX, XYRlineMY
8229  global X0LXY # Left top X value
8230  global Y0TXY # Left top Y value
8231  global GRWXY # Screenwidth
8232  global GRHXY # Screenheight
8233  global FontSize, LabelPlotText, PlotLabelText
8234  global XYca, MouseX, MouseY, MouseWidget
8235  global ShowXCur, ShowYCur, XCursor, YCursor
8236  global SHOWsamples # Number of samples in data record
8237  global ShowMath, MathUnits, MathXUnits, MathYUnits
8238  global Xsignal, MathAxis, MathXAxis, MathYAxis
8239  global YsignalVA, YsignalIA, YsignalVB, YsignalIB, YsignalM, YsignalMY, YsignalMX
8240  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
8241  global RUNstatus, SingleShot, ManualTrigger # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
8242  global CHAsbxy # spinbox Index for channel 1 V
8243  global CHBsbxy # spinbox Index for channel 2 V
8244  global CHAOffset # Offset value for channel 1 V
8245  global CHBOffset # Offset value for channel 2 V
8246  global CHAIsbxy # spinbox Index for channel 1 I
8247  global CHBIsbxy # spinbox Index for channel 2 I
8248  global CHAIOffset # Offset value for channel 1 I
8249  global CHBIOffset # Offset value for channel 2 I
8250  global TMpdiv # Array with time / div values in ms
8251  global TMsb # Time per div spin box variable
8252  global TIMEdiv # current spin box value
8253  global SAMPLErate
8254  global TRIGGERsample, TRIGGERlevel, HoldOff, HoldOffentry
8255  global COLORgrid, COLORzeroline, COLORtext, COLORtrigger, COLORtrace6, COLORtrace7 # The colors
8256  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5
8257  global COLORtraceR1, COLORtraceR2, COLORtraceR3, COLORtraceR4, COLORtraceR5, COLORtraceR6, COLORtraceR7
8258  global CANVASwidthXY, CANVASheightXY, COLORXmarker, COLORYmarker
8259  global TRACErefresh, TRACEmode, TRACEwidth, GridWidth
8260  global ScreenXYrefresh, SmoothCurves
8261  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
8262  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
8263  global SV1, SI1, SV2, SI2, CHABphase
8264  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
8265  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
8266  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
8267  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
8268  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase
8269  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
8270  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
8271  global AWGAShape, AWGBShape
8272  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
8273  global CHAVPosEntry, CHAIPosEntry, CHAVPosEntry, CHBIPosEntry
8274  global CH1pdvRange, CHAOffset, CH2pdvRange, CHBOffset
8275  global DacScreenStatus, DigScreenStatus
8276  global D0, D1, D2, D3, D4, D5, D6, D7
8277  global DevID, devx, MarkerNum, MarkerScale
8278  global HozPoss, HozPossentry
8279  global HistAsPercent, VBuffA, VBuffB, HBuffA, HBuffB
8280  global VABase, VATop, VBBase, VBTop, UserALabel, UserAString, UserBLabel, UserBString
8281  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2, MeasUserA, MeasUserB
8282  #
8283  Ymin = Y0TXY # Minimum position of screen grid (top)
8284  Ymax = Y0TXY + GRHXY # Maximum position of screen grid (bottom)
8285  RightOffset = FontSize * 3
8286  LeftOffset = int(FontSize/2)
8287  try:
8288  InOffA = float(eval(CHAVOffsetEntry.get()))
8289  except:
8290  CHAVOffsetEntry.delete(0,END)
8291  CHAVOffsetEntry.insert(0, InOffA)
8292  try:
8293  InGainA = float(eval(CHAVGainEntry.get()))
8294  except:
8295  CHAVGainEntry.delete(0,END)
8296  CHAVGainEntry.insert(0, InGainA)
8297  try:
8298  InOffB = float(eval(CHBVOffsetEntry.get()))
8299  except:
8300  CHBVOffsetEntry.delete(0,END)
8301  CHBVOffsetEntry.insert(0, InOffB)
8302  try:
8303  InGainB = float(eval(CHBVGainEntry.get()))
8304  except:
8305  CHBVGainEntry.delete(0,END)
8306  CHBVGainEntry.insert(0, InGainB)
8307 #
8308  try:
8309  CH1pdvRange = float(eval(CHAsbxy.get()))
8310  except:
8311  CHAsbxy.delete(0,END)
8312  CHAsbxy.insert(0, CH1pdvRange)
8313  try:
8314  CH2pdvRange = float(eval(CHBsbxy.get()))
8315  except:
8316  CHBsbxy.delete(0,END)
8317  CHBsbxy.insert(0, CH2pdvRange)
8318  try:
8319  CH1IpdvRange = float(eval(CHAIsbxy.get()))
8320  except:
8321  CHAIsbxy.delete(0,END)
8322  CHAIsbxy.insert(0, CH1IpdvRange)
8323  try:
8324  CH2IpdvRange = float(eval(CHBIsbxy.get()))
8325  except:
8326  CHBIsbxy.delete(0,END)
8327  CHBIsbxy.insert(0, CH2IpdvRange)
8328  # get the vertical offsets
8329  try:
8330  CHAOffset = float(eval(CHAVPosEntryxy.get()))
8331  except:
8332  CHAVPosEntryxy.delete(0,END)
8333  CHAVPosEntryxy.insert(0, CHAOffset)
8334  try:
8335  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
8336  except:
8337  CHAIPosEntryxy.delete(0,END)
8338  CHAIPosEntryxy.insert(0, CHAIOffset)
8339  try:
8340  CHBOffset = float(eval(CHBVPosEntryxy.get()))
8341  except:
8342  CHBVPosEntry.delete(0,END)
8343  CHBVPosEntry.insert(0, CHBOffset)
8344  try:
8345  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
8346  except:
8347  CHBIPosEntryxy.delete(0,END)
8348  CHBIPosEntryxy.insert(0, CHBIOffset)
8349  # prevent divide by zero error
8350  if CH1pdvRange < 0.001:
8351  CH1pdvRange = 0.001
8352  if CH2pdvRange < 0.001:
8353  CH2pdvRange = 0.001
8354  if CH1IpdvRange < 0.05:
8355  CH1IpdvRange = 0.05
8356  if CH2IpdvRange < 0.05:
8357  CH2IpdvRange = 0.05
8358  # If drawing histograms adjust offset based on range such that bottom grid is zero
8359  if Xsignal.get() == 6:
8360  CHAIOffset = 5 * CH1IpdvRange
8361  if Xsignal.get() == 7:
8362  CHBIOffset = 5 * CH2IpdvRange
8363  if ScreenXYrefresh.get() == 0:
8364  # Delete all items on the screen
8365  MarkerNum = 0
8366  XYca.delete(ALL) # remove all items
8367  # Draw horizontal grid lines
8368  i = 0
8369  x1 = X0LXY
8370  x2 = X0LXY + GRWXY
8371  mg_siz = GRWXY/10.0
8372  mg_inc = mg_siz/5.0
8373  while (i < 11):
8374  y = Y0TXY + i * GRHXY/10.0
8375  Dline = [x1,y,x2,y]
8376  if i == 5:
8377  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
8378  k = 0
8379  while (k < 10):
8380  l = 1
8381  while (l < 5):
8382  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
8383  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8384  l = l + 1
8385  k = k + 1
8386  else:
8387  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8388  if YsignalIA.get() == 1 or Xsignal.get() == 6:
8389  Iaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8390  Iaxis_label = str(round(Iaxis_value, 3))
8391  XYca.create_text(x2+LeftOffset, y, text=Iaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
8392  if YsignalIB.get() == 1 or Xsignal.get() == 7:
8393  Iaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8394  Iaxis_label = str(round(Iaxis_value, 3))
8395  XYca.create_text(x2+RightOffset, y, text=Iaxis_label, fill=COLORtrace4, anchor="w", font=("arial", FontSize ))
8396  if YsignalVA.get() == 1:
8397  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8398  Vaxis_label = str(round(Vaxis_value, 3))
8399  XYca.create_text(x1-LeftOffset, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
8400  if YsignalVB.get() == 1:
8401  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8402  Vaxis_label = str(round(Vaxis_value, 3))
8403  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=COLORtrace2, anchor="e", font=("arial", FontSize ))
8404  if YsignalM.get() == 1:
8405  TempCOLOR = COLORtrace5
8406  if MathTrace.get() == 2:
8407  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8408  elif MathTrace.get() == 3:
8409  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8410  else:
8411  if MathAxis == "V-A":
8412  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8413  TempCOLOR = COLORtrace1
8414  elif MathAxis == "V-B":
8415  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8416  TempCOLOR = COLORtrace2
8417  elif MathAxis == "I-A":
8418  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8419  TempCOLOR = COLORtrace3
8420  elif MathAxis == "I-B":
8421  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8422  TempCOLOR = COLORtrace4
8423  else:
8424  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8425  Vaxis_label = str(round(Vaxis_value, 3))
8426  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8427  if YsignalMX.get() == 1:
8428  TempCOLOR = COLORtrace6
8429  if MathXAxis == "V-A":
8430  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8431  TempCOLOR = COLORtrace1
8432  elif MathXAxis == "V-B":
8433  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8434  TempCOLOR = COLORtrace2
8435  elif MathXAxis == "I-A":
8436  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8437  TempCOLOR = COLORtrace3
8438  elif MathXAxis == "I-B":
8439  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8440  TempCOLOR = COLORtrace4
8441  else:
8442  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8443  Vaxis_label = str(round(Vaxis_value, 3))
8444  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8445  if YsignalMY.get() == 1:
8446  TempCOLOR = COLORtrace7
8447  if MathYAxis == "V-A":
8448  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8449  TempCOLOR = COLORtrace1
8450  elif MathYAxis == "V-B":
8451  Vaxis_value = (((5-i) * CH2pdvRange ) + CHBOffset)
8452  TempCOLOR = COLORtrace2
8453  elif MathYAxis == "I-A":
8454  Vaxis_value = 1.0 * (((5-i) * CH1IpdvRange ) + CHAIOffset)
8455  TempCOLOR = COLORtrace3
8456  elif MathYAxis == "I-B":
8457  Vaxis_value = 1.0 * (((5-i) * CH2IpdvRange ) + CHBIOffset)
8458  TempCOLOR = COLORtrace4
8459  else:
8460  Vaxis_value = (((5-i) * CH1pdvRange ) + CHAOffset)
8461  Vaxis_label = str(round(Vaxis_value, 3))
8462  XYca.create_text(x1-RightOffset, y, text=Vaxis_label, fill=TempCOLOR, anchor="e", font=("arial", FontSize ))
8463  i = i + 1
8464  # Draw vertical grid lines
8465  i = 0
8466  y1 = Y0TXY
8467  y2 = Y0TXY + GRHXY
8468  mg_siz = GRHXY/10.0
8469  mg_inc = mg_siz/5.0
8470  #
8471  while (i < 11):
8472  x = X0LXY + i * GRWXY/10.0
8473  Dline = [x,y1,x,y2]
8474  if (i == 5):
8475  XYca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
8476  k = 0
8477  while (k < 10):
8478  l = 1
8479  while (l < 5):
8480  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
8481  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8482  l = l + 1
8483  k = k + 1
8484  if Xsignal.get() == 1 or Xsignal.get() == 6: #
8485  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8486  Vaxis_label = str(round(Vaxis_value, 3))
8487  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
8488  elif Xsignal.get() == 3 or Xsignal.get() == 7:
8489  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8490  Vaxis_label = str(round(Vaxis_value, 3))
8491  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
8492  elif Xsignal.get() == 2:
8493  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8494  Iaxis_label = str(round(Iaxis_value, 3))
8495  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
8496  elif Xsignal.get() == 4:
8497  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8498  Iaxis_label = str(round(Iaxis_value, 3))
8499  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
8500  elif Xsignal.get() == 5:
8501  TempCOLOR = COLORtrace5
8502  if MathTrace.get() == 2:
8503  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8504  elif MathTrace.get() == 3:
8505  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8506  else:
8507  if MathXAxis == "V-A":
8508  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8509  TempCOLOR = COLORtrace1
8510  elif MathXAxis == "V-B":
8511  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8512  TempCOLOR = COLORtrace2
8513  elif MathXAxis == "I-A":
8514  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8515  TempCOLOR = COLORtrace3
8516  elif MathXAxis == "I-B":
8517  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8518  TempCOLOR = COLORtrace4
8519  else:
8520  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8521  TempCOLOR = COLORtrace5
8522  Vaxis_label = str(round(Vaxis_value, 3))
8523  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
8524  else:
8525  XYca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
8526  if Xsignal.get() == 1 or Xsignal.get() == 6:
8527  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8528  Vaxis_label = str(round(Vaxis_value, 3))
8529  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
8530  elif Xsignal.get() == 3 or Xsignal.get() == 7:
8531  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8532  Vaxis_label = str(round(Vaxis_value, 3))
8533  XYca.create_text(x, y2+3, text=Vaxis_label, fill=COLORtrace2, anchor="n", font=("arial", FontSize ))
8534  elif Xsignal.get() == 2:
8535  Iaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8536  Iaxis_label = str(round(Iaxis_value, 3))
8537  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
8538  elif Xsignal.get() == 4:
8539  Iaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8540  Iaxis_label = str(round(Iaxis_value, 3))
8541  XYca.create_text(x, y2+3, text=Iaxis_label, fill=COLORtrace4, anchor="n", font=("arial", FontSize ))
8542  elif Xsignal.get() == 5:
8543  TempCOLOR = COLORtrace5
8544  if MathTrace.get() == 2:
8545  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8546  elif MathTrace.get() == 3:
8547  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8548  else:
8549  if MathXAxis == "V-A":
8550  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8551  TempCOLOR = COLORtrace1
8552  elif MathXAxis == "V-B":
8553  Vaxis_value = (((i-5) * CH2pdvRange ) + CHBOffset)
8554  TempCOLOR = COLORtrace2
8555  elif MathXAxis == "I-A":
8556  Vaxis_value = 1.0 * (((i-5) * CH1IpdvRange ) + CHAIOffset)
8557  TempCOLOR = COLORtrace3
8558  elif MathXAxis == "I-B":
8559  Vaxis_value = 1.0 * (((i-5) * CH2IpdvRange ) + CHBIOffset)
8560  TempCOLOR = COLORtrace4
8561  else:
8562  Vaxis_value = (((i-5) * CH1pdvRange ) + CHAOffset)
8563  Vaxis_label = str(round(Vaxis_value, 3))
8564  XYca.create_text(x, y2+3, text=Vaxis_label, fill=TempCOLOR, anchor="n", font=("arial", FontSize ))
8565  i = i + 1
8566 # Draw traces
8567 # Avoid writing lines with 1 coordinate
8568  if YsignalVA.get() == 1:
8569  if len(XYlineVA) > 4:
8570  XYca.create_line(XYlineVA, fill=COLORtrace1, width=TRACEwidth.get())
8571  if YsignalIA.get() == 1:
8572  if len(XYlineIA) > 4:
8573  XYca.create_line(XYlineIA, fill=COLORtrace3, width=TRACEwidth.get())
8574  if YsignalVB.get() == 1:
8575  if len(XYlineVB) > 4:
8576  XYca.create_line(XYlineVB, fill=COLORtrace2, width=TRACEwidth.get())
8577  if YsignalIB.get() == 1:
8578  if len(XYlineIB) > 4:
8579  XYca.create_line(XYlineIB, fill=COLORtrace4, width=TRACEwidth.get())
8580  if YsignalM.get() == 1: # or Ysignal.get() == 5:
8581  if len(XYlineM) > 4:
8582  XYca.create_line(XYlineM, fill=COLORtrace5, width=TRACEwidth.get())
8583  if YsignalMX.get() == 1:
8584  if len(XYlineMX) > 4:
8585  XYca.create_line(XYlineMX, fill=COLORtrace6, width=TRACEwidth.get())
8586  if YsignalMY.get() == 1:
8587  if len(XYlineMY) > 4:
8588  XYca.create_line(XYlineMY, fill=COLORtrace7, width=TRACEwidth.get())
8589  if len(XYRlineVA) > 4 and XYRefAV.get() == 1:
8590  XYca.create_line(XYRlineVA, fill=COLORtraceR1, width=TRACEwidth.get())
8591  if len(XYRlineVB) > 4 and XYRefBV.get() == 1:
8592  XYca.create_line(XYRlineVB, fill=COLORtraceR2, width=TRACEwidth.get())
8593  if len(XYRlineIA) > 4 and XYRefAI.get() == 1:
8594  XYca.create_line(XYRlineIA, fill=COLORtraceR3, width=TRACEwidth.get())
8595  if len(XYRlineIB) > 4 and XYRefBI.get() == 1:
8596  XYca.create_line(XYRlineIB, fill=COLORtraceR4, width=TRACEwidth.get())
8597  if len(XYRlineM) > 4 and XYRefM.get() == 1:
8598  XYca.create_line(XYRlineM, fill=COLORtraceR5, width=TRACEwidth.get())
8599  if len(XYRlineMX) > 4 and XYRefMX.get() == 1:
8600  XYca.create_line(XYRlineMX, fill=COLORtraceR6, width=TRACEwidth.get())
8601  if len(XYRlineMY) > 4 and XYRefMY.get() == 1:
8602  XYca.create_line(XYRlineMY, fill=COLORtraceR7, width=TRACEwidth.get())
8603 # Draw Histogram Traces
8604  if Xsignal.get() == 6:
8605  MakeHistogram()
8606  b = 0
8607  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8608  Xconv1 = float(GRWXY/10.0) / CH1pdvRange
8609  y1 = Y0TXY + GRHXY
8610  # print Yconv1, y1
8611  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
8612  while b < 4999: #
8613  if HistAsPercent == 1: # convert to percent of total sample count
8614  ylo = float(HBuffA[0][b]) / len(VBuffA)
8615  ylo = ylo * 100.0
8616  else:
8617  ylo = HBuffA[0][b] #
8618  ylo = int(y1 - (Yconv1 * ylo))
8619  if ylo > Ymax:
8620  ylo = Ymax
8621  if ylo < Ymin:
8622  ylo = Ymin
8623  xlo = HBuffA[1][b] - CHAOffset
8624  xlo = int(c2 + Xconv1 * xlo)
8625  Dline = [xlo,y1,xlo,ylo]
8626  XYca.create_line(Dline, fill=COLORtrace1)
8627  b = b + 1
8628  if Xsignal.get() == 7:
8629  MakeHistogram()
8630  b = 0
8631  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8632  Xconv1 = float(GRWXY/10.0) / CH2pdvRange
8633  y1 = Y0TXY + GRHXY
8634  c2 = GRWXY / 2.0 + X0LXY # Hor correction factor
8635  while b < 4999: #
8636  if HistAsPercent == 1: # convert to percent
8637  ylo = float(HBuffB[0][b]) / len(VBuffB)
8638  ylo = ylo * 100.0
8639  else:
8640  ylo = HBuffB[0][b]
8641  ylo = int(y1 - Yconv1 * ylo)
8642  if ylo > Ymax:
8643  ylo = Ymax
8644  if ylo < Ymin:
8645  ylo = Ymin
8646  xlo = HBuffB[1][b] - CHBOffset
8647  xlo = int(c2 + Xconv1 * xlo)
8648  Dline = [xlo,y1,xlo,ylo]
8649  XYca.create_line(Dline, fill=COLORtrace2)
8650  b = b + 1
8651 # Draw X - Y Cursor lines if required
8652  COLORXmarker = COLORtrace1
8653  COLORYmarker = COLORtrace2
8654  if Xsignal.get() == 1 or Xsignal.get() == 6:
8655  Xconv1 = float(GRWXY/10) / CH1pdvRange
8656  Xoffset1 = CHAOffset
8657  COLORXmarker = COLORtrace1
8658  X_label = " V"
8659  if Xsignal.get() == 2:
8660  Xconv1 = float(GRWXY/10) / CH1IpdvRange
8661  Xoffset1 = CHAIOffset
8662  COLORXmarker = COLORtrace3
8663  X_label = " mA"
8664  if Xsignal.get() == 3 or Xsignal.get() == 7:
8665  Xconv1 = float(GRWXY/10) / CH2pdvRange
8666  Xoffset1 = CHBOffset
8667  COLORXmarker = COLORtrace2
8668  X_label = " V"
8669  if Xsignal.get() == 4:
8670  Xconv1 = float(GRWXY/10) / CH2IpdvRange
8671  Xoffset1 = CHBIOffset
8672  COLORmarker = COLORtrace4
8673  X_label = " mA"
8674  if Xsignal.get() == 5:
8675  X_label = MathXUnits
8676  if MathXAxis == "V-A":
8677  Xconv1 = float(GRWXY/10) / CH1pdvRange
8678  Xoffset1 = CHAOffset
8679  COLORXmarker = COLORtrace1
8680  elif MathXAxis == "V-B":
8681  Xconv1 = float(GRWXY/10) / CH2pdvRange
8682  Xoffset1 = CHBOffset
8683  COLORXmarker = COLORtrace2
8684  elif MathXAxis == "I-A":
8685  Xconv1 = float(GRWXY/10) / CH1IpdvRange
8686  Xoffset1 = CHAIOffset
8687  COLORXmarker = COLORtrace3
8688  elif MathXAxis == "I-B":
8689  Xconv1 = float(GRWXY/10) / CH2IpdvRange
8690  Xoffset1 = CHBIOffset
8691  COLORXmarker = COLORtrace4
8692  else:
8693  Xconv1 = float(GRWXY/10) / CH1pdvRange
8694  Xoffset1 = CHAOffset
8695  COLORXmarker = COLORtrace1
8696 #
8697  if YsignalVA.get() == 1 or YsignalM.get() == 1:
8698  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8699  Yoffset1 = CHAOffset
8700  COLORYmarker = COLORtrace1
8701  Y_label = " V"
8702  if YsignalIA.get() == 1:
8703  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8704  Yoffset1 = CHAIOffset
8705  COLORYmarker = COLORtrace3
8706  Y_label = " mA"
8707  if YsignalVB.get() == 1 or YsignalM.get() == 1:
8708  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
8709  Yoffset1 = CHBOffset
8710  COLORYmarker = COLORtrace2
8711  Y_label = " V"
8712  if YsignalIB.get() == 1:
8713  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8714  Yoffset1 = CHBIOffset
8715  COLORYmarker = COLORtrace4
8716  Y_label = " mA"
8717  if YsignalM.get() == 1 or YsignalMX.get() == 1 or YsignalMY.get() == 1:
8718  Y_label = MathYUnits
8719  if MathYAxis == "V-A":
8720  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8721  Yoffset1 = CHAOffset
8722  COLORYmarker = COLORtrace1
8723  elif MathYAxis == "V-B":
8724  Yconv1 = float(GRHXY/10.0) / CH2pdvRange
8725  Yoffset1 = CHBOffset
8726  COLORYmarker = COLORtrace2
8727  elif MathYAxis == "I-A":
8728  Yconv1 = float(GRHXY/10.0) / CH1IpdvRange
8729  Yoffset1 = CHAIOffset
8730  COLORYmarker = COLORtrace3
8731  elif MathYAxis == "I-B":
8732  Yconv1 = float(GRHXY/10.0) / CH2IpdvRange
8733  Yoffset1 = CHBIOffset
8734  COLORYmarker = COLORtrace4
8735  else:
8736  Yconv1 = float(GRHXY/10.0) / CH1pdvRange
8737  Yoffset1 = CHAOffset
8738  COLORYmarker = COLORtrace1
8739  if ShowXCur.get() > 0:
8740  Dline = [XCursor, Y0TXY, XCursor, Y0TXY+GRHXY]
8741  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
8742  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
8743  xvolts = Xoffset1 - ((c1-XCursor)/Xconv1)
8744  XString = ' {0:.3f} '.format(xvolts)
8745  V_label = XString + X_label
8746  XYca.create_text(XCursor+1, YCursor-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
8747  if ShowYCur.get() > 0:
8748  Dline = [X0LXY, YCursor, X0LXY+GRWXY, YCursor]
8749  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
8750  c1 = GRHXY / 2.0 + Y0TXY # fixed Y correction
8751  yvolts = ((YCursor-c1)/Yconv1) - Yoffset1
8752  V1String = ' {0:.3f} '.format(-yvolts)
8753  V_label = V1String + Y_label
8754  XYca.create_text(XCursor+1, YCursor+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
8755  if ShowXCur.get() == 0 and ShowYCur.get() == 0 and MouseWidget == XYca:
8756  if MouseX > X0LXY and MouseX < X0LXY+GRWXY and MouseY > Y0TXY and MouseY < Y0TXY+GRHXY:
8757  Dline = [MouseX, Y0TXY, MouseX, Y0TXY+GRHXY]
8758  XYca.create_line(Dline, dash=(4,3), fill=COLORXmarker, width=GridWidth.get())
8759  c1 = GRWXY / 2.0 + X0LXY # fixed X correction
8760  xvolts = Xoffset1 - ((c1-MouseX)/Xconv1) # XCursor
8761  XString = ' {0:.3f} '.format(xvolts)
8762  V_label = XString + X_label
8763  XYca.create_text(MouseX+1, MouseY-5, text=V_label, fill=COLORXmarker, anchor="w", font=("arial", FontSize ))
8764  Dline = [X0LXY, MouseY, X0LXY+GRWXY, MouseY]
8765  XYca.create_line(Dline, dash=(4,3), fill=COLORYmarker, width=GridWidth.get())
8766  c1 = GRHXY / 2 + Y0TXY # fixed Y correction
8767  yvolts = ((MouseY-c1)/Yconv1) - Yoffset1
8768  V1String = ' {0:.3f} '.format(-yvolts)
8769  V_label = V1String + Y_label
8770  XYca.create_text(MouseX+1, MouseY+5, text=V_label, fill=COLORYmarker, anchor="w", font=("arial", FontSize ))
8771 #
8772 # General information on top of the grid
8773 # Sweep information
8774  sttxt = "Running"
8775  if TRACEmodeTime.get() == 1:
8776  sttxt = sttxt + " Averaging"
8777  if ManualTrigger.get() == 1:
8778  sttxt = "Manual Trigger"
8779  if (RUNstatus.get() == 0) or (RUNstatus.get() == 3):
8780  sttxt = "Stopped"
8781  if ScreenXYrefresh.get() == 1:
8782  sttxt = sttxt + " Persistance ON"
8783  # Delete text at bottom of screen
8784  de = XYca.find_enclosed( X0LXY-1, Y0TXY+GRHXY+19, CANVASwidthXY, Y0TXY+GRHXY+100)
8785  for n in de:
8786  XYca.delete(n)
8787  # Delete text at top of screen
8788  de = XYca.find_enclosed( X0LXY-1, -1, CANVASwidthXY, 20)
8789  for n in de:
8790  XYca.delete(n)
8791  if LabelPlotText.get() > 0:
8792  txt = PlotLabelText + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8793  else:
8794  txt = "Device ID " + DevID[17:31] + " Sample rate: " + str(SAMPLErate) + " " + sttxt
8795  x = X0LXY
8796  y = 12
8797  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8798  # digital I/O indicators
8799  x2 = X0LXY + GRWXY
8800  BoxColor = "#808080" # gray
8801  if DacScreenStatus.get() == 0 and DigScreenStatus.get() == 1 :
8802  if D0.get() == 0 and D4.get() == 0:
8803  Dval = devx.ctrl_transfer( 0xc0, 0x91, 4, 0, 0, 1, 100)
8804  if Dval[0] == 1:
8805  BoxColor = "#00ff00" # 100% green
8806  elif Dval[0] == 0:
8807  BoxColor = "#ff0000" # 100% red
8808  XYca.create_rectangle(x2-12, 6, x2, 18, fill=BoxColor)
8809  else:
8810  XYca.create_rectangle(x2-12, 6, x2, 18, fill="yellow")
8811  if D1.get() == 0 and D5.get() == 0:
8812  Dval = devx.ctrl_transfer( 0xc0, 0x91, 5, 0, 0, 1, 100)
8813  if Dval[0] == 1:
8814  BoxColor = "#00ff00" # 100% green
8815  elif Dval[0] == 0:
8816  BoxColor = "#ff0000" # 100% red
8817  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill=BoxColor)
8818  else:
8819  XYca.create_rectangle(x2-26, 6, x2-14, 18, fill="yellow")
8820  if D2.get() == 0 and D6.get() == 0:
8821  Dval = devx.ctrl_transfer( 0xc0, 0x91, 6, 0, 0, 1, 100)
8822  if Dval[0] == 1:
8823  BoxColor = "#00ff00" # 100% green
8824  elif Dval[0] == 0:
8825  BoxColor = "#ff0000" # 100% red
8826  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill=BoxColor)
8827  else:
8828  XYca.create_rectangle(x2-40, 6, x2-28, 18, fill="yellow")
8829  if D3.get() == 0 and D7.get() == 0:
8830  Dval = devx.ctrl_transfer( 0xc0, 0x91, 7, 0, 0, 1, 100)
8831  if Dval[0] == 1:
8832  BoxColor = "#00ff00" # 100% green
8833  elif Dval[0] == 0:
8834  BoxColor = "#ff0000" # 100% red
8835  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill=BoxColor)
8836  else:
8837  XYca.create_rectangle(x2-54, 6, x2-42, 18, fill="yellow")
8838  XYca.create_text(x2-56, 12, text="Digital Inputs", anchor=E, fill=COLORtext)
8839  # print period and frequency of displayed channels
8840  txt = " "
8841  if Xsignal.get() == 1 or Xsignal.get() == 3:
8842  FindRisingEdge(VBuffA, VBuffB)
8843  if Xsignal.get() == 1:
8844  if MeasAHW.get() == 1:
8845  txt = txt + " CA Hi Width = " + ' {0:.2f} '.format(CHAHW) + " mS "
8846  if MeasALW.get() == 1:
8847  txt = txt + " CA Lo Width = " + ' {0:.2f} '.format(CHALW) + " mS "
8848  if MeasADCy.get() == 1:
8849  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
8850  if MeasAPER.get() == 1:
8851  txt = txt + " CA Period = " + ' {0:.2f} '.format(CHAperiod) + " mS "
8852  if MeasAFREQ.get() == 1:
8853  txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
8854  if Xsignal.get() == 3:
8855  if MeasBHW.get() == 1:
8856  txt = txt + " CB Hi Width = " + ' {0:.2f} '.format(CHBHW) + " mS "
8857  if MeasBLW.get() == 1:
8858  txt = txt + " CB Lo Width = " + ' {0:.2f} '.format(CHBLW) + " mS "
8859  if MeasBDCy.get() == 1:
8860  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
8861  if MeasBPER.get() == 1:
8862  txt = txt + " CB Period = " + ' {0:.2f} '.format(CHBperiod) + " mS "
8863  if MeasBFREQ.get() == 1:
8864  txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
8865  if MeasPhase.get() == 1:
8866  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
8867 
8868  x = X0LXY
8869  y = Y0TXY+GRHXY+int(2.5*FontSize) # 20
8870  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8871  txt = " "
8872  if Xsignal.get() == 1 or YsignalVA.get() == 1 or Xsignal.get() == 6:
8873  # Channel A information
8874  txt = "CHA: "
8875  txt = txt + str(CH1pdvRange) + " V/div"
8876  if MeasDCV1.get() == 1:
8877  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
8878  if MeasMaxV1.get() == 1:
8879  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
8880  if MeasTopV1.get() == 1:
8881  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
8882  if MeasMinV1.get() == 1:
8883  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
8884  if MeasBaseV1.get() == 1:
8885  txt = txt + " Top = " + ' {0:.4f} '.format(VABase)
8886  if MeasMidV1.get() == 1:
8887  MidV1 = (MaxV1+MinV1)/2
8888  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
8889  if MeasPPV1.get() == 1:
8890  PPV1 = MaxV1-MinV1
8891  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
8892  if MeasRMSV1.get() == 1:
8893  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
8894  if MeasUserA.get() == 1:
8895  try:
8896  TempValue = eval(UserAString)
8897  V1String = ' {0:.4f} '.format(TempValue)
8898  except:
8899  V1String = "####"
8900  txt = txt + UserALabel + " = " + V1String
8901  if Xsignal.get() == 2:
8902  txt = "CHA: "
8903  txt = txt + str(CH1IpdvRange) + " mA/div"
8904  elif (Xsignal.get() == 2):
8905  txt = txt + "CHA: "
8906  txt = txt + str(CH1IpdvRange) + " mA/div"
8907  if Xsignal.get() == 2 or YsignalIA.get() == 1:
8908  if MeasDCI1.get() == 1:
8909  V1String = ' {0:.2f} '.format(DCI1)
8910  txt = txt + " AvgI = " + V1String
8911  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
8912  try:
8913  Resvalue = (DCV1/DCI1)*1000
8914  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8915  except:
8916  txt = txt + " Res = OverRange"
8917  if MeasMaxI1.get() == 1:
8918  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
8919  if MeasMinI1.get() == 1:
8920  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
8921  if MeasMidI1.get() == 1:
8922  MidI1 = (MaxI1+MinI1)/2
8923  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
8924  if MeasPPI1.get() == 1:
8925  PPI1 = MaxI1-MinI1
8926  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
8927  if MeasRMSI1.get() == 1:
8928  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
8929 
8930  x = X0LXY
8931  y = Y0TXY+GRHXY+int(4*FontSize) # 32
8932  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8933  txt= " "
8934  # Channel B information
8935  if Xsignal.get() == 3 or YsignalVB.get() == 1 or Xsignal.get() == 7:
8936  txt = "CHB: "
8937  txt = txt + str(CH2pdvRange) + " V/div"
8938  if MeasDCV2.get() == 1:
8939  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
8940  if MeasMaxV2.get() == 1:
8941  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
8942  if MeasTopV2.get() == 1:
8943  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
8944  if MeasMinV2.get() == 1:
8945  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
8946  if MeasBaseV2.get() == 1:
8947  txt = txt + " Top = " + ' {0:.4f} '.format(VBBase)
8948  if MeasMidV2.get() == 1:
8949  MidV2 = (MaxV2+MinV2)/2
8950  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
8951  if MeasPPV2.get() == 1:
8952  PPV2 = MaxV2-MinV2
8953  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
8954  if MeasRMSV2.get() == 1:
8955  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
8956  if MeasUserB.get() == 1:
8957  try:
8958  TempValue = eval(UserBString)
8959  V1String = ' {0:.4f} '.format(TempValue)
8960  except:
8961  V1String = "####"
8962  txt = txt + UserBLabel + " = " + V1String
8963  if Xsignal.get() == 4:
8964  txt = "CHB: "
8965  txt = txt + str(CH2IpdvRange) + " mA/div"
8966  elif Xsignal.get() == 4:
8967  txt = txt + "CHB: "
8968  txt = txt + str(CH2IpdvRange) + " mA/div"
8969  if Xsignal.get() == 4 or YsignalIB.get() == 1:
8970  if MeasDCI2.get() == 1:
8971  V1String = ' {0:.2f} '.format(DCI2)
8972  txt = txt + " AvgI = " + V1String
8973  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
8974  try:
8975  Resvalue = (DCV2/DCI2)*1000
8976  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
8977  except:
8978  txt = txt + " Res = OverRange"
8979  if MeasMaxI2.get() == 1:
8980  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
8981  if MeasMinI2.get() == 1:
8982  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
8983  if MeasMidI2.get() == 1:
8984  MidI2 = (MaxI2+MinI2)/2
8985  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
8986  if MeasPPI2.get() == 1:
8987  PPI2 = MaxI2-MinI2
8988  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
8989  if MeasRMSI2.get() == 1:
8990  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
8991 
8992  x = X0LXY
8993  y = Y0TXY+GRHXY+int(5.5 * FontSize) # 44
8994  XYca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
8995 #
8997  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
8998 
8999  if MarkerScale.get() != 1:
9000  MarkerScale.set(1)
9001  CHAlab.config(style="Rtrace1.TButton")
9002  CHBlab.config(style="Strace2.TButton")
9003  CHAIlab.config(style="Strace3.TButton")
9004  CHBIlab.config(style="Strace4.TButton")
9005  else:
9006  MarkerScale.set(0)
9007 #
9009  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9010 
9011  if MarkerScale.get() != 3:
9012  MarkerScale.set(3)
9013  CHAlab.config(style="Strace1.TButton")
9014  CHBlab.config(style="Strace2.TButton")
9015  CHAIlab.config(style="Rtrace3.TButton")
9016  CHBIlab.config(style="Strace4.TButton")
9017  else:
9018  MarkerScale.set(0)
9019 
9021  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9022 
9023  if MarkerScale.get() != 2:
9024  MarkerScale.set(2)
9025  CHAlab.config(style="Strace1.TButton")
9026  CHBlab.config(style="Rtrace2.TButton")
9027  CHAIlab.config(style="Strace3.TButton")
9028  CHBIlab.config(style="Strace4.TButton")
9029  else:
9030  MarkerScale.set(0)
9031 
9033  global MarkerScale, CHAlab, CHBlab, CHAIlab, CHBIlab
9034 
9035  if MarkerScale.get() != 3:
9036  MarkerScale.set(4)
9037  CHAlab.config(style="Strace1.TButton")
9038  CHBlab.config(style="Strace2.TButton")
9039  CHAIlab.config(style="Strace3.TButton")
9040  CHBIlab.config(style="Rtrace4.TButton")
9041  else:
9042  MarkerScale.set(0)
9043 #
9045  global MarkerXYScale, CHAxylab, CHBxylab
9046 
9047  MarkerXYScale.set(1)
9048  CHAxylab.config(style="Rtrace1.TButton")
9049  CHBxylab.config(style="Strace2.TButton")
9050 
9052  global MarkerXYScale, CHAxylab, CHBxylab
9053 
9054  MarkerXYScale.set(2)
9055  CHBxylab.config(style="Rtrace2.TButton")
9056  CHAxylab.config(style="Strace1.TButton")
9057 #
9059  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca
9060 
9061  TCursor = event.x
9062  VCursor = event.y
9063  if RUNstatus.get() == 0:
9065  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
9066 
9068  global ShowTCur, ShowVCur, TCursor, VCursor, RUNstatus, ca, MWcount
9069  global MeasGateStatus, MeasGateLeft, MeasGateRight, TIMEdiv, GRW
9070 
9071  ShiftKeyDwn = event.state & 1
9072  if event.widget == ca:
9073  if ShowTCur.get() > 0 or ShowVCur.get() > 0: # move cursors if shown
9074  if ShowTCur.get() > 0 and ShiftKeyDwn == 0:
9075  # respond to Linux or Windows wheel event
9076  if event.num == 5 or event.delta == -120:
9077  TCursor -= 1
9078  if event.num == 4 or event.delta == 120:
9079  TCursor += 1
9080  elif ShowVCur.get() > 0 or ShiftKeyDwn == 1:
9081  # respond to Linux or Windows wheel event
9082  if event.num == 5 or event.delta == -120:
9083  VCursor += 1
9084  if event.num == 4 or event.delta == 120:
9085  VCursor -= 1
9086 
9090  else:
9091  if MeasGateStatus.get() == 1:
9092  Tstep = (TIMEdiv / GRW) / 10 # time in mS per pixel
9093  if ShiftKeyDwn == 0:
9094  if event.num == 5 or event.delta == -120:
9095  MeasGateLeft = MeasGateLeft + (-100 * Tstep)
9096  if event.num == 4 or event.delta == 120:
9097  MeasGateLeft = MeasGateLeft + (100 * Tstep)
9098  # MeasGateLeft = MeasGateLeft + (event.delta * Tstep) #+ HoldOff
9099  if ShiftKeyDwn == 1:
9100  if event.num == 5 or event.delta == -120:
9101  MeasGateRight = MeasGateRight + (-100 * Tstep)
9102  if event.num == 4 or event.delta == 120:
9103  MeasGateRight = MeasGateRight + (100 * Tstep)
9104  #MeasGateRight = MeasGateRight + (event.delta * Tstep) #+ HoldOff
9105  try:
9106  onSpinBoxScroll(event) # if cursor are not showing scroll the Horx time base
9107  except:
9108  donothing()
9109  if RUNstatus.get() == 0:
9111 
9112 def onCanvasUpArrow(event):
9113  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca, Bodeca
9114 
9115  shift_key = event.state & 1
9116  if event.widget == ca:
9117  if ShowVCur.get() > 0 and shift_key == 0:
9118  VCursor = VCursor - 1
9119  elif ShowVCur.get() > 0 and shift_key == 1:
9120  VCursor = VCursor - 5
9121  if RUNstatus.get() == 0:
9123  try:
9124  if event.widget == XYca:
9125  if ShowYCur.get() > 0 and shift_key == 0:
9126  YCursor = YCursor - 1
9127  elif ShowYCur.get() > 0 and shift_key == 1:
9128  YCursor = YCursor - 5
9129  if RUNstatus.get() == 0:
9130  UpdateXYScreen()
9131  except:
9132  donothing()
9133  try:
9134  if event.widget == Freqca:
9135  if ShowdBCur.get() > 0 and shift_key == 0:
9136  dBCursor = dBCursor - 1
9137  elif ShowdBCur.get() > 0 and shift_key == 1:
9138  dBCursor = dBCursor - 5
9139  if RUNstatus.get() == 0:
9141  except:
9142  donothing()
9143  try:
9144  if event.widget == Bodeca:
9145  if ShowBdBCur.get() > 0 and shift_key == 0:
9146  BdBCursor = BdBCursor - 1
9147  elif ShowBdBCur.get() > 0 and shift_key == 1:
9148  BdBCursor = BdBCursor - 5
9149  if RUNstatus.get() == 0:
9151  except:
9152  donothing()
9153 
9155  global ShowVCur, VCursor, YCursor, dBCursor, BdBCursor, RUNstatus, ca, XYca, Freqca
9156 
9157  shift_key = event.state & 1
9158  if event.widget == ca:
9159  if ShowVCur.get() > 0 and shift_key == 0:
9160  VCursor = VCursor + 1
9161  elif ShowVCur.get() > 0 and shift_key == 1:
9162  VCursor = VCursor + 5
9163  if RUNstatus.get() == 0:
9165  try:
9166  if event.widget == XYca:
9167  if ShowYCur.get() > 0 and shift_key == 0:
9168  YCursor = YCursor + 1
9169  elif ShowYCur.get() > 0 and shift_key == 1:
9170  YCursor = YCursor + 5
9171  if RUNstatus.get() == 0:
9172  UpdateXYScreen()
9173  except:
9174  donothing()
9175  try:
9176  if event.widget == Freqca:
9177  if ShowdBCur.get() > 0 and shift_key == 0:
9178  dBCursor = dBCursor + 1
9179  elif ShowdBCur.get() > 0 and shift_key == 1:
9180  dBCursor = dBCursor + 5
9181  if RUNstatus.get() == 0:
9183  except:
9184  donothing()
9185  try:
9186  if event.widget == Bodeca:
9187  if ShowBdBCur.get() > 0 and shift_key == 0:
9188  BdBCursor = BdBCursor + 1
9189  elif ShowBdBCur.get() > 0 and shift_key == 1:
9190  BdBCursor = BdBCursor + 5
9191  if RUNstatus.get() == 0:
9193  except:
9194  donothing()
9195 
9197  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9198 
9199  shift_key = event.state & 1
9200  if event.widget == ca:
9201  if ShowTCur.get() > 0 and shift_key == 0:
9202  TCursor = TCursor - 1
9203  elif ShowTCur.get() > 0 and shift_key == 1:
9204  TCursor = TCursor - 5
9205  if RUNstatus.get() == 0:
9207  try:
9208  if event.widget == XYca:
9209  if ShowXCur.get() > 0 and shift_key == 0:
9210  XCursor = XCursor - 1
9211  elif ShowXCur.get() > 0 and shift_key == 1:
9212  XCursor = XCursor - 5
9213  if RUNstatus.get() == 0:
9214  UpdateXYScreen()
9215  except:
9216  donothing()
9217  try:
9218  if event.widget == Freqca:
9219  if ShowFCur.get() > 0 and shift_key == 0:
9220  FCursor = FCursor - 1
9221  elif ShowFCur.get() > 0 and shift_key == 1:
9222  FCursor = FCursor - 5
9223  if RUNstatus.get() == 0:
9225  except:
9226  donothing()
9227  try:
9228  if event.widget == Bodeca:
9229  if ShowBPCur.get() > 0 and shift_key == 0:
9230  BPCursor = BPCursor - 1
9231  elif ShowBPCur.get() > 0 and shift_key == 1:
9232  BPCursor = BPCursor - 5
9233  if RUNstatus.get() == 0:
9235  except:
9236  donothing()
9237 
9239  global ShowTCur, TCursor, XCursor, FCursor, BPCursor, RUNstatus, ca, XYca, Freqca
9240 
9241  shift_key = event.state & 1
9242  if event.widget == ca:
9243  if ShowTCur.get() > 0 and shift_key == 0:
9244  TCursor = TCursor + 1
9245  elif ShowTCur.get() > 0 and shift_key == 1:
9246  TCursor = TCursor + 5
9247  if RUNstatus.get() == 0:
9249  try:
9250  if event.widget == XYca:
9251  if ShowXCur.get() > 0 and shift_key == 0:
9252  XCursor = XCursor + 1
9253  elif ShowXCur.get() > 0 and shift_key == 1:
9254  XCursor = XCursor + 5
9255  if RUNstatus.get() == 0:
9256  UpdateXYScreen()
9257  except:
9258  donothing()
9259  try:
9260  if event.widget == Freqca:
9261  if ShowFCur.get() > 0 and shift_key == 0:
9262  FCursor = FCursor + 1
9263  elif ShowFCur.get() > 0 and shift_key == 1:
9264  FCursor = FCursor + 5
9265  if RUNstatus.get() == 0:
9267  except:
9268  donothing()
9269  try:
9270  if event.widget == Bodeca:
9271  if ShowBPCur.get() > 0 and shift_key == 0:
9272  BPCursor = BPCursor + 1
9273  elif ShowBPCur.get() > 0 and shift_key == 1:
9274  BPCursor = BPCursor + 5
9275  if RUNstatus.get() == 0:
9277  except:
9278  donothing()
9279 
9280 def onCanvasSpaceBar(event):
9281  global RUNstatus, ca, XYca, Freqca, Bodeca, IAca
9282 
9283  if event.widget == ca:
9284  if RUNstatus.get() == 0:
9285  BStart()
9286  elif RUNstatus.get() > 0:
9287  BStop()
9288  try:
9289  if event.widget == XYca:
9290  if RUNstatus.get() == 0:
9291  BStart()
9292  elif RUNstatus.get() > 0:
9293  BStop()
9294  except:
9295  donothing()
9296  try:
9297  if event.widget == IAca:
9298  if RUNstatus.get() == 0:
9299  BStart()
9300  elif RUNstatus.get() > 0:
9301  BStop()
9302  except:
9303  donothing()
9304  try:
9305  if event.widget == Freqca:
9306  if RUNstatus.get() == 0:
9307  BStartSA()
9308  elif RUNstatus.get() > 0:
9309  BStopSA()
9310  except:
9311  donothing()
9312  try:
9313  if event.widget == Bodeca:
9314  if RUNstatus.get() == 0:
9315  BStartBP()
9316  elif RUNstatus.get() > 0:
9317  BStopBP()
9318  except:
9319  donothing()
9320 #
9322  global X0L # Left top X value
9323  global Y0T # Left top Y value
9324  global GRW # Screenwidth
9325  global GRH # Screenheight
9326  global FontSize
9327  global ca, MarkerLoc, Mulx, Roll_Mode
9328  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9329  global TMsb, CHAsb, CHBsb, CHAIsb, CHBIsb, MarkerScale
9330  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry
9331  global SAMPLErate, RUNstatus, MarkerNum, PrevV, PrevT
9332  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9333  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9334  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9335  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
9336  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
9337  global MeasGateLeft, MeasGateRight, MeasGateStatus, MeasGateNum, TMsb, SAMPLErate
9338 
9339  try:
9340  HoldOff = float(eval(HoldOffentry.get()))
9341  if HoldOff < 0:
9342  HoldOff = 0
9343  except:
9344  HoldOffentry.delete(0,END)
9345  HoldOffentry.insert(0, HoldOff)
9346  # get time scale
9347  try:
9348  TIMEdiv = float(eval(TMsb.get()))
9349  except:
9350  TIMEdiv = 0.5
9351  TMsb.delete(0,"end")
9352  TMsb.insert(0,TIMEdiv)
9353  # prevent divide by zero error
9354  if TIMEdiv < 0.0002:
9355  TIMEdiv = 0.01
9356  # add markers only if stopped
9357  if (RUNstatus.get() == 0):
9358  MarkerNum = MarkerNum + 1
9359  # get the vertical ranges
9360  try:
9361  CH1pdvRange = float(eval(CHAsb.get()))
9362  except:
9363  CHAsb.delete(0,END)
9364  CHAsb.insert(0, CH1pdvRange)
9365  try:
9366  CH2pdvRange = float(eval(CHBsb.get()))
9367  except:
9368  CHBsb.delete(0,END)
9369  CHBsb.insert(0, CH2pdvRange)
9370  try:
9371  CH1IpdvRange = float(eval(CHAIsb.get()))
9372  except:
9373  CHAIsb.delete(0,END)
9374  CHAIsb.insert(0, CH1IpdvRange)
9375  try:
9376  CH2IpdvRange = float(eval(CHBIsb.get()))
9377  except:
9378  CHBIsb.delete(0,END)
9379  CHBIsb.insert(0, CH2IpdvRange)
9380  # get the vertical offsets
9381  try:
9382  CHAOffset = float(eval(CHAVPosEntry.get()))
9383  except:
9384  CHAVPosEntry.delete(0,END)
9385  CHAVPosEntry.insert(0, CHAOffset)
9386  try:
9387  CHAIOffset = float(eval(CHAIPosEntry.get()))
9388  except:
9389  CHAIPosEntry.delete(0,END)
9390  CHAIPosEntry.insert(0, CHAIOffset)
9391  try:
9392  CHBOffset = float(eval(CHBVPosEntry.get()))
9393  except:
9394  CHBVPosEntry.delete(0,END)
9395  CHBVPosEntry.insert(0, CHBOffset)
9396  try:
9397  CHBIOffset = float(eval(CHBIPosEntry.get()))
9398  except:
9399  CHBIPosEntry.delete(0,END)
9400  CHBIPosEntry.insert(0, CHBIOffset)
9401  # prevent divide by zero error
9402  if CH1pdvRange < 0.001:
9403  CH1pdvRange = 0.001
9404  if CH2pdvRange < 0.001:
9405  CH2pdvRange = 0.001
9406  if CH1IpdvRange < 1.0:
9407  CH1IpdvRange = 1.0
9408  if CH2IpdvRange < 1.0:
9409  CH2IpdvRange = 1.0
9410 #
9411  if MuxScreenStatus.get() == 1: # if using analog Mux set up axis controls
9412  try:
9413  CHMApdvRange = float(eval(CHB_Asb.get()))
9414  except:
9415  CHB_Asb.delete(0,END)
9416  CHB_Asb.insert(0, CHMApdvRange)
9417  try:
9418  CHMBpdvRange = float(eval(CHB_Bsb.get()))
9419  except:
9420  CHB_Bsb.delete(0,END)
9421  CHB_Bsb.insert(0, CHMBpdvRange)
9422  try:
9423  CHMCpdvRange = float(eval(CHB_Csb.get()))
9424  except:
9425  CHB_Csb.delete(0,END)
9426  CHB_Csb.insert(0, CHMCpdvRange)
9427  try:
9428  CHMDpdvRange = float(eval(CHB_Dsb.get()))
9429  except:
9430  CHB_Dsb.delete(0,END)
9431  CHB_Dsb.insert(0, CHMDpdvRange)
9432  YconvMA = float(GRH/10.0) / CHMApdvRange
9433  YconvMB = float(GRH/10.0) / CHMBpdvRange
9434  YconvMC = float(GRH/10.0) / CHMCpdvRange
9435  YconvMD = float(GRH/10.0) / CHMDpdvRange
9436  try:
9437  CHBAOffset = float(eval(CHB_APosEntry.get()))
9438  except:
9439  CHB_APosEntry.delete(0,END)
9440  CHB_APosEntry.insert(0, CHBAOffset)
9441  try:
9442  CHBBOffset = float(eval(CHB_BPosEntry.get()))
9443  except:
9444  CHB_BPosEntry.delete(0,END)
9445  CHB_BPosEntry.insert(0, CHBBOffset)
9446  try:
9447  CHBCOffset = float(eval(CHB_CPosEntry.get()))
9448  except:
9449  CHB_CPosEntry.delete(0,END)
9450  CHB_CPosEntry.insert(0, CHBCOffset)
9451  try:
9452  CHBDOffset = float(eval(CHB_DPosEntry.get()))
9453  except:
9454  CHB_DPosEntry.delete(0,END)
9455  CHB_DPosEntry.insert(0, CHBDOffset)
9456  Yoffset1 = CHAOffset
9457  if MarkerScale.get() == 1:
9458  Yconv1 = float(GRH/10.0) / CH1pdvRange
9459  Yoffset1 = CHAOffset
9460  COLORmarker = COLORtrace1
9461  Units = " V"
9462  elif MarkerScale.get() == 2:
9463  Yconv1 = float(GRH/10.0) / CH2pdvRange
9464  Yoffset1 = CHBOffset
9465  COLORmarker = COLORtrace2
9466  Units = " V"
9467  elif MarkerScale.get() == 3:
9468  Yconv1 = float(GRH/10.0) / CH1IpdvRange
9469  Yoffset1 = CHAIOffset
9470  COLORmarker = COLORtrace3
9471  Units = " mA"
9472  elif MarkerScale.get() == 4:
9473  Yconv1 = float(GRH/10.0) / CH2IpdvRange
9474  Yoffset1 = CHBIOffset
9475  COLORmarker = COLORtrace4
9476  Units = " mA"
9477  # Aanalog Mux settings
9478  elif MarkerScale.get() == 5:
9479  Yconv1 = float(GRH/10.0) / CHMApdvRange
9480  Yoffset1 = CHBAOffset
9481  COLORmarker = COLORtrace2
9482  Units = " V"
9483  elif MarkerScale.get() == 6:
9484  Yconv1 = float(GRH/10.0) / CHMBpdvRange
9485  Yoffset1 = CHBBOffset
9486  COLORmarker = COLORtrace6
9487  Units = " V"
9488  elif MarkerScale.get() == 7:
9489  Yconv1 = float(GRH/10.0) / CHMCpdvRange
9490  Yoffset1 = CHBCOffset
9491  COLORmarker = COLORtrace7
9492  Units = " V"
9493  elif MarkerScale.get() == 8:
9494  Yconv1 = float(GRH/10.0) / CHMDpdvRange
9495  Yoffset1 = CHBDOffset
9496  COLORmarker = COLORtrace4
9497  Units = " V"
9498  else:
9499  Yconv1 = float(GRH/10.0) / CH1pdvRange
9500  Yoffset1 = CHAOffset
9501  COLORmarker = COLORtrace1
9502  Units = " V"
9503  #
9504  c1 = GRH / 2.0 + Y0T # fixed correction channel A
9505  xc1 = GRW / 2.0 + X0L
9506  c2 = GRH / 2.0 + Y0T # fixed correction channel B
9507  # draw X at marker point and number
9508  ca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
9509  ca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
9510  # DISsamples = (10.0 * TIMEdiv) # grid width in time
9511  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
9512  Tpoint = ((event.x-X0L) * Tstep) + HoldOff
9513  #
9514  Tpoint = Tpoint/Mulx
9515  if Tpoint >= 1000:
9516  axis_value = Tpoint / 1000.0
9517  TString = ' {0:.2f} '.format(axis_value) + " S "
9518  if Tpoint < 1000 and Tpoint >= 1:
9519  axis_value = Tpoint
9520  TString = ' {0:.2f} '.format(axis_value) + " mS "
9521  if Tpoint < 1:
9522  axis_value = Tpoint * 1000.0
9523  TString = ' {0:.2f} '.format(axis_value) + " uS "
9524  # TString = ' {0:.2f} '.format(Tpoint)
9525  yvolts = ((event.y-c1)/Yconv1) - Yoffset1
9526  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
9527  V1String = ' {0:.3f} '.format(-yvolts)
9528  else:
9529  V1String = ' {0:.1f} '.format(-yvolts)
9530  V_label = str(MarkerNum) + " " + TString + V1String
9531  V_label = V_label + Units
9532  if MarkerNum > 1:
9533  if MarkerScale.get() == 1 or MarkerScale.get() == 2:
9534  DeltaV = ' {0:.3f} '.format(PrevV-yvolts)
9535  else:
9536  DeltaV = ' {0:.1f} '.format(PrevV-yvolts)
9537  if Roll_Mode.get() == 0: # should be same as First_Slow_sweep == 0
9538  DT = (Tpoint-PrevT)
9539  if Tpoint >= 1000:
9540  axis_value = DT / 1000.0
9541  DeltaT = ' {0:.2f} '.format(axis_value) + " S "
9542  if Tpoint < 1000 and Tpoint >= 1:
9543  axis_value = DT
9544  DeltaT = ' {0:.2f} '.format(axis_value) + " mS "
9545  if Tpoint < 1:
9546  axis_value = DT * 1000.0
9547  DeltaT = ' {0:.2f} '.format(axis_value) + " uS "
9548  # DeltaT = ' {0:.3f} '.format(Tpoint-PrevT)
9549  DFreq = ' {0:.3f} '.format(1.0/(Tpoint-PrevT))
9550  V_label = V_label + " Delta " + DeltaT + DeltaV
9551  V_label = V_label + Units
9552  V_label = V_label + ", Freq " + DFreq + " KHz"
9553  else:
9554  V_label = V_label + " Delta " + DeltaV + Units
9555  # place in upper left unless specified otherwise
9556  x = X0L + 5
9557  y = Y0T + 3 + (MarkerNum*10)
9558  Justify = 'w'
9559  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
9560  x = X0L + GRW - 5
9561  y = Y0T + 3 + (MarkerNum*10)
9562  Justify = 'e'
9563  if MarkerLoc == 'LL' or MarkerLoc == 'll':
9564  x = X0L + 5
9565  y = Y0T + GRH + 3 - (MarkerNum*10)
9566  Justify = 'w'
9567  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
9568  x = X0L + GRW - 5
9569  y = Y0T + GRH + 3 - (MarkerNum*10)
9570  Justify = 'e'
9571  ca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor=Justify, font=("arial", FontSize ))
9572  ca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
9573  PrevV = yvolts
9574  PrevT = Tpoint
9575  else:
9576  if MeasGateStatus.get() == 1:
9577  #DISsamples = (10.0 * TIMEdiv) # grid width in time
9578  Tstep = (10.0 * TIMEdiv) / GRW # time in mS per pixel
9579  if MeasGateNum == 0:
9580  MeasGateLeft = ((event.x-X0L) * Tstep) #+ HoldOff
9581  MeasGateNum = 1
9582  else:
9583  MeasGateRight = ((event.x-X0L) * Tstep) #+ HoldOff
9584  MeasGateNum = 0
9585  LeftGate = X0L + MeasGateLeft / Tstep
9586  RightGate = X0L + MeasGateRight / Tstep
9587  ca.create_line(LeftGate, Y0T, LeftGate, Y0T+GRH, fill=COLORtext)
9588  ca.create_line(RightGate, Y0T, RightGate, Y0T+GRH, fill=COLORtext)
9589 
9590 #
9591 def onCanvasOne(event):
9592  global ShowC1_V
9593 
9594  if ShowC1_V.get() == 0:
9595  ShowC1_V.set(1)
9596  else:
9597  ShowC1_V.set(0)
9598 #
9599 def onCanvasTwo(event):
9600  global ShowC2_V
9601 
9602  if ShowC2_V.get() == 0:
9603  ShowC2_V.set(1)
9604  else:
9605  ShowC2_V.set(0)
9606 #
9607 def onCanvasThree(event):
9608  global ShowC1_I
9609 
9610  if ShowC1_I.get() == 0:
9611  ShowC1_I.set(1)
9612  else:
9613  ShowC1_I.set(0)
9614 #
9615 def onCanvasFour(event):
9616  global ShowC2_I
9617 
9618  if ShowC2_I.get() == 0:
9619  ShowC2_I.set(1)
9620  else:
9621  ShowC2_I.set(0)
9622 #
9623 def onCanvasFive(event):
9624  global MathTrace
9625 
9626  MathTrace.set(1)
9627 #
9628 def onCanvasSix(event):
9629  global MathTrace
9630 
9631  MathTrace.set(2)
9632 #
9633 def onCanvasSeven(event):
9634  global MathTrace
9635 
9636  MathTrace.set(3)
9637 #
9638 def onCanvasEight(event):
9639  global MathTrace
9640 
9641  MathTrace.set(10)
9642 #
9643 def onCanvasNine(event):
9644  global MathTrace
9645 
9646  MathTrace.set(12)
9647 #
9648 def onCanvasZero(event):
9649  global MathTrace
9650 
9651  MathTrace.set(0)
9652 #
9653 def onCanvasTrising(event):
9654  global TgEdge
9655 
9656  TgEdge.set(0)
9657 #
9658 def onCanvasTfalling(event):
9659  global TgEdge
9660 
9661  TgEdge.set(1)
9662 #
9663 def onCanvasSnap(event):
9664 
9665  BSnapShot()
9666 #
9667 def onCanvasAverage(event):
9668  global TRACEmodeTime
9669 
9670  if TRACEmodeTime.get() == 0:
9671  TRACEmodeTime.set(1)
9672  else:
9673  TRACEmodeTime.set(0)
9674 #
9675 def onCanvasShowTcur(event):
9676  global ShowTCur
9677 
9678  if ShowTCur.get() == 0:
9679  ShowTCur.set(1)
9680  else:
9681  ShowTCur.set(0)
9682 #
9683 def onCanvasShowVcur(event):
9684  global ShowVCur
9685 
9686  if ShowVCur.get() == 0:
9687  ShowVCur.set(1)
9688  else:
9689  ShowVCur.set(0)
9690 #
9692  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus, XYca
9693 
9694  XCursor = event.x
9695  YCursor = event.y
9696  if RUNstatus.get() == 0:
9697  UpdateXYScreen()
9698  XYca.bind_all('<MouseWheel>', onCanvasXYScrollClick)
9699 #
9701  global ShowXCur, ShowYCur, XCursor, YCursor, RUNstatus
9702  if event.widget == XYca:
9703  if ShowXCur.get() > 0 or ShowYCur.get() > 0: # move cursors if shown
9704  ShiftKeyDwn = event.state & 1
9705  if ShowXCur.get() > 0 and ShiftKeyDwn == 0:
9706  # respond to Linux or Windows wheel event
9707  if event.num == 5 or event.delta == -120:
9708  XCursor -= 1
9709  if event.num == 4 or event.delta == 120:
9710  XCursor += 1
9711  # XCursor = XCursor + event.delta/100
9712  elif ShowYCur.get() > 0 or ShiftKeyDwn == 1:
9713  # respond to Linux or Windows wheel event
9714  if event.num == 5 or event.delta == -120:
9715  YCursor += 1
9716  if event.num == 4 or event.delta == 120:
9717  YCursor -= 1
9718  #YCursor = YCursor - event.delta/100
9719  if RUNstatus.get() == 0:
9720  UpdateXYScreen()
9721 #
9723  global X0LXY # Left top X value
9724  global Y0TXY # Left top Y value
9725  global GRWXY # Screenwidth
9726  global GRHXY # Screenheight
9727  global FontSize
9728  global XYca
9729  global HoldOffentry, Xsignal, Ysignal, COLORgrid, COLORtext
9730  global TMsb, CHAsbxy, CHBsbxy, CHAIsbxy, CHBIsbxy, MarkerScale
9731  global CHAVPosEntryxy, CHAIPosEntryxy, CHBVPosEntryxy, CHBIPosEntryxy
9732  global SAMPLErate, RUNstatus, MarkerNum, PrevX, PrevY
9733  global COLORtrace1, COLORtrace2, MathUnits, MathXUnits, MathYUnits
9734  global CH1pdvRange, CH2pdvRange, CH1IpdvRange, CH2IpdvRange
9735  global CHAOffset, CHAIOffset, CHBOffset, CHBIOffset
9736  # add markers only if stopped
9737  #
9738  if (RUNstatus.get() == 0):
9739  MarkerNum = MarkerNum + 1
9740  try:
9741  CH1pdvRange = float(eval(CHAsbxy.get()))
9742  except:
9743  CHAsbxy.delete(0,END)
9744  CHAsbxy.insert(0, CH1pdvRange)
9745  try:
9746  CH2pdvRange = float(eval(CHBsbxy.get()))
9747  except:
9748  CHBsb.delete(0,END)
9749  CHBsb.insert(0, CH2pdvRange)
9750  try:
9751  CH1IpdvRange = float(eval(CHAIsbxy.get()))
9752  except:
9753  CHAIsbxy.delete(0,END)
9754  CHAIsbxy.insert(0, CH1IpdvRange)
9755  try:
9756  CH2IpdvRange = float(eval(CHBIsbxy.get()))
9757  except:
9758  CHBIsbxy.delete(0,END)
9759  CHBIsbxy.insert(0, CH2IpdvRange)
9760  # get the vertical offsets
9761  try:
9762  CHAOffset = float(eval(CHAVPosEntryxy.get()))
9763  except:
9764  CHAVPosEntryxy.delete(0,END)
9765  CHAVPosEntryxy.insert(0, CHAOffset)
9766  try:
9767  CHAIOffset = float(eval(CHAIPosEntryxy.get()))
9768  except:
9769  CHAIPosEntryxy.delete(0,END)
9770  CHAIPosEntryxy.insert(0, CHAIOffset)
9771  try:
9772  CHBOffset = float(eval(CHBVPosEntryxy.get()))
9773  except:
9774  CHBVPosEntryxy.delete(0,END)
9775  CHBVPosEntryxy.insert(0, CHBOffset)
9776  try:
9777  CHBIOffset = float(eval(CHBIPosEntryxy.get()))
9778  except:
9779  CHBIPosEntryxy.delete(0,END)
9780  CHBIPosEntryxy.insert(0, CHBIOffset)
9781  # prevent divide by zero error
9782  if CH1pdvRange < 0.001:
9783  CH1pdvRange = 0.001
9784  if CH2pdvRange < 0.001:
9785  CH2pdvRange = 0.001
9786  if CH1IpdvRange < 1.0:
9787  CH1IpdvRange = 1.0
9788  if CH2IpdvRange < 1.0:
9789  CH2IpdvRange = 1.0
9790  try:
9791  HoldOff = float(eval(HoldOffentry.get()))
9792  if HoldOff < 0:
9793  HoldOff = 0
9794  except:
9795  HoldOffentry.delete(0,END)
9796  HoldOffentry.insert(0, HoldOff)
9797  #
9798  Yconv1 = float(GRHXY/10) / CH1pdvRange # Conversion factors from samples to screen points
9799  Xconv1 = float(GRWXY/10) / CH1pdvRange
9800  Yconv2 = float(GRHXY/10) / CH2pdvRange
9801  Xconv2 = float(GRWXY/10) / CH2pdvRange
9802  YIconv1 = float(GRHXY/10) / CH1IpdvRange
9803  YIconv2 = float(GRHXY/10) / CH2IpdvRange
9804  COLORmarker = COLORtext
9805  Yoffset1 = CHAOffset
9806  c1 = GRHXY / 2 + Y0TXY # fixed correction channel A
9807  xc1 = GRWXY / 2 + X0LXY
9808  c2 = GRHXY / 2 + Y0TXY # fixed correction channel B
9809  # draw X at marker point and number
9810  XYca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORtext)
9811  XYca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORtext)
9812  XYca.create_text(event.x+4, event.y, text=str(MarkerNum), fill=COLORtext, anchor="w", font=("arial", FontSize ))
9813  V_label = str(MarkerNum) + " "
9814  x = X0LXY + 5
9815  y = Y0TXY + 3 + (MarkerNum*10)
9816  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset # preset the variable
9817  if (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==3 or Ysignal.get()==5):
9818  yvolts = ((event.y-c2)/Yconv2) - CHBOffset
9819  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9820  VyString = ' {0:.3f} '.format(-yvolts)
9821  VxString = ' {0:.3f} '.format(-xvolts)
9822  V_label = V_label + VxString + " V, " + VyString + " V"
9823  if MarkerNum > 1:
9824  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
9825  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9826  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
9827  PrevY = yvolts
9828  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==1 or Ysignal.get()==5):
9829  yvolts = ((event.y-c1)/Yconv1) - CHAOffset
9830  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9831  VyString = ' {0:.3f} '.format(-yvolts)
9832  VxString = ' {0:.3f} '.format(-xvolts)
9833  V_label = V_label + VxString + " V, " + VyString + " V"
9834  if MarkerNum > 1:
9835  DeltaY = ' {0:.3f} '.format(PrevY-yvolts)
9836  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9837  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " V"
9838  PrevY = yvolts
9839  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
9840  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9841  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
9842  VxString = ' {0:.3f} '.format(-xvolts)
9843  VyString = ' {0:.1f} '.format(-ymA)
9844  V_label = V_label + VxString + " V, " + VyString + " mA"
9845  if MarkerNum > 1:
9846  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9847  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9848  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9849  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9850  V_label = V_label + ", dV/dI " + DeltaR
9851  PrevY = ymA
9852  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
9853  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9854  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
9855  VxString = ' {0:.3f} '.format(-xvolts)
9856  VyString = ' {0:.1f} '.format(-ymA)
9857  V_label = V_label + VxString + " V, " + VyString + " mA"
9858  if MarkerNum > 1:
9859  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9860  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9861  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9862  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9863  V_label = V_label + ", dV/dI " + DeltaR
9864  PrevY = ymA
9865  elif (Xsignal.get()==3 or Xsignal.get()==5) and (Ysignal.get()==2 or Ysignal.get()==5):
9866  xvolts = ((xc1-event.x)/Xconv2) - CHBOffset
9867  ymA = ((event.y-c2)/YIconv1) - CHAIOffset
9868  VxString = ' {0:.3f} '.format(-xvolts)
9869  VyString = ' {0:.1f} '.format(-ymA)
9870  V_label = V_label + VxString + " V, " + VyString + " mA"
9871  if MarkerNum > 1:
9872  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9873  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9874  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9875  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9876  V_label = V_label + ", dV/dI " + DeltaR
9877  PrevY = ymA
9878  elif (Xsignal.get()==1 or Xsignal.get()==5) and (Ysignal.get()==4 or Ysignal.get()==5):
9879  xvolts = ((xc1-event.x)/Xconv1) - CHAOffset
9880  ymA = ((event.y-c2)/YIconv2) - CHBIOffset
9881  VxString = ' {0:.3f} '.format(-xvolts)
9882  VyString = ' {0:.1f} '.format(-ymA)
9883  V_label = V_label + VxString + " V, " + VyString + " mA"
9884  if MarkerNum > 1:
9885  DeltaY = ' {0:.2f} '.format(PrevY-ymA)
9886  DeltaX = ' {0:.3f} '.format(PrevX-xvolts)
9887  DeltaR = ' {0:.3f} '.format(((PrevX-xvolts)/(PrevY-ymA))*1000)
9888  V_label = V_label + " Delta " + DeltaX + " V, " + DeltaY + " mA"
9889  V_label = V_label + ", dV/dI " + DeltaR
9890  PrevY = ymA
9891  XYca.create_text(x, y, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
9892  PrevX = xvolts
9893 #
9894 # Some DSP functions
9895 #
9896 # Generate Time-series From Half-spectrum code block
9897 # takes: a desired noise spectral density array (freq)
9898 # the sample rate of the time series (fs),
9899 # returns a time series of voltage samples that can be sent to the AWG
9900 #
9901 # DC in first element.
9902 # Output length is 2x input length
9903 def time_points_from_freq(freq, fs=1, density=False):
9904  N=len(freq)
9905  rnd_ph_pos = (numpy.ones(N-1, dtype=numpy.complex)*
9906  numpy.exp(1j*numpy.random.uniform
9907  (0.0,2.0*numpy.pi, N-1)))
9908  rnd_ph_neg = numpy.flip(numpy.conjugate(rnd_ph_pos))
9909  rnd_ph_full = numpy.concatenate(([1],rnd_ph_pos,[1], rnd_ph_neg))
9910  r_s_full = numpy.concatenate((freq, numpy.roll(numpy.flip(freq), 1)))
9911  r_spectrum_rnd_ph = r_s_full * rnd_ph_full
9912  r_time_full = numpy.fft.ifft(r_spectrum_rnd_ph)
9913 # print("RMS imaginary component: ",
9914 # np.std(np.imag(r_time_full)),
9915 # " Should be close to nothing")
9916  if (density == True):
9917  #Note that this N is "predivided" by 2
9918  r_time_full *= N*numpy.sqrt(fs/(N))
9919  return(numpy.real(r_time_full))
9920 #
9921 def TimeSeriesNoise(n, Fsample, mag, b=4):
9922  # Build Noise Time-series
9923  # n = number of Freq Bins
9924  # b = number of noise bands
9925  # Fsample is Sample Rate
9926  # generates four "bands" of mag V/rootHz noise
9927  mag = mag * 0.707106 # scale by 1/sqrt 2 for RMS
9928  width = int(n/(4 * b))
9929  i = 1
9930  aband = numpy.ones(width)
9931  zband = numpy.zeros(width)
9932  bands = numpy.concatenate((aband, zband))
9933  while i < b:
9934  bands = numpy.concatenate((bands, aband, zband))
9935  i = i + 1
9936  bands = bands*mag
9937  bands[0] = 0.0 # Set DC bin content to zero
9938  return time_points_from_freq(bands, fs=Fsample, density=True)
9939 #
9940 # Generate Time samples for single frequency Bin
9941 # Uses IFFT
9942 #
9943 def TimeSeriesSingleTone(n, BinNum, Fsample, mag):
9944  # Build Single tone Time-series
9945  # n = number of Freq Bins
9946  # BinNum = FFT Bin number
9947  # Fsample is Sample Rate
9948  # mag is tone amplitude
9949  bands = numpy.zeros(n)
9950  bands[BinNum] = 1
9951  bands = bands * (mag/2.0)
9952  return time_points_from_freq(bands, fs=Fsample, density=True)
9953 #
9954 def PinkNoise(N, mag):
9955  # Pink noise.
9956  # Pink noise has equal power in bands that are proportionally wide.
9957  # Power spectral density decreases with 3 dB per octave.
9958  # N Length of sample array, mag magnitude scaling factor
9959 
9960  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
9961  X = numpy.fft.rfft(x) / N
9962  S = numpy.sqrt(numpy.arange(X.size)+1.0) # +1 to avoid divide by zero
9963  y = numpy.fft.irfft(X/S).real[:N] # extremely tiny value 1e-9 without normalization
9964  z = numpy.ndarray = mag
9965  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
9966 
9967  return y
9968 #
9969 def BlueNoise(N, mag):
9970  # Blue noise.
9971  # Power increases with 6 dB per octave.
9972  # Power spectral density increases with 3 dB per octave.
9973  # N Length of sample array, mag magnitude scaling factor
9974 
9975  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
9976  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
9977  X = numpy.fft.rfft(x) / N
9978  S = numpy.sqrt(numpy.arange(X.size)) # Filter
9979  y = numpy.fft.irfft(X*S).real[:N]
9980  z = numpy.ndarray = mag
9981  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
9982 
9983  return y
9984 #
9985 def BrownNoise(N, mag):
9986  # Brown noise.
9987  # Power decreases with -3 dB per octave.
9988  # Power spectral density decreases with 6 dB per octave.
9989  # N Length of sample array, mag magnitude scaling factor
9990 
9991  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
9992  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
9993  X = numpy.fft.rfft(x) / N
9994  S = numpy.arange(X.size)+1 # Filter
9995  y = numpy.fft.irfft(X/S).real[:N]
9996  z = numpy.ndarray = mag
9997  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
9998 
9999  return y
10000 #
10001 def VioletNoise(N, mag):
10002  # Violet noise.
10003  # Power increases with +9 dB per octave.
10004  # Power density increases with +6 dB per octave.
10005  # N Length of sample array, mag magnitude scaling factor
10006 
10007  # x = numpy.random.randn(N).astype(numpy.float32) # white Noise
10008  x = numpy.random.normal(0.0, 1, N).astype(numpy.float32) # white Noise
10009  X = numpy.fft.rfft(x) / N
10010  S = numpy.arange(X.size) # Filter
10011  y = numpy.fft.irfft(X*S).real[0:N]
10012  z = numpy.ndarray = mag
10013  y = y * numpy.sqrt((numpy.abs(z)**2).mean() / (numpy.abs(y)**2).mean())
10014 
10015  return y
10016 #
10017 def SchroederPhase(Length, NrTones, Ampl):
10018  # Generate a Schroeder Phase (Chirp) of Length samples and having NrTones
10019  OutArray = []
10020  OutArray = Ampl*numpy.cos(numpy.linspace(0, 2*numpy.pi, Length)) # the fundamental
10021  k = 2
10022  while k <= NrTones:
10023  # Add all harmonics up to NrTones
10024  Harmonic = Ampl*numpy.cos(numpy.linspace(0, k*2*numpy.pi, Length)+(numpy.pi*k*k/NrTones))
10025  OutArray = OutArray + Harmonic
10026  k = k + 1
10027  OutArray = OutArray + 2.5 # Center wavefrom on 2.5 V
10028  return(OutArray)
10029 #
10030 def Wrap(InArray, WrFactor):
10031  # Build new array by skipping WrFactor samples and wrapping back around
10032  # [1,2,3,4,5,6} becomes [1,3,5,2,4,6]
10033  # effectively multiplies the frequency content by WrFactor
10034  OutArray = []
10035  OutArray = numpy.array(OutArray)
10036  InArray = numpy.array(InArray)
10037  EndIndex = len(InArray)
10038  StartIndex = 0
10039  while StartIndex < WrFactor:
10040  OutArray = numpy.concatenate((OutArray, InArray[StartIndex:EndIndex:WrFactor]), axis=0)
10041  StartIndex = StartIndex + 1
10042  return OutArray
10043 #
10044 def UnWrap(InArray, WrFactor):
10045  # Build new array by splitting arrray into WrFactor sections and interleaving samples from each section
10046  # [1,2,3,4,5,6} becomes [1,4,2,5,3,6]
10047  # effectively divided the frequency content by WrFactor
10048  OutArray = []
10049  InArray = numpy.array(InArray)
10050  EndIndex = int(len(InArray)/WrFactor)
10051  StartIndex = 0
10052  while StartIndex < EndIndex:
10053  LoopIndex = 0
10054  while LoopIndex < WrFactor:
10055  OutArray.append(InArray[StartIndex+LoopIndex])
10056  LoopIndex = LoopIndex + 1
10057  StartIndex = StartIndex + 1
10058  OutArray = numpy.array(OutArray)
10059  return OutArray
10060 #
10061 def Write_WAV(data, repeat, filename):
10062  global SAMPLErate
10063  # write data array to mono .wav file 100KSPS
10064  # copy buffer repeat times in output file
10065  # Use : Write_WAV(VBuffB, 2, "write_wave_1.wav")
10066  wavfile = wave.open(filename, "w")
10067  nchannels = 1
10068  sampwidth = 2
10069  framerate = SAMPLErate
10070  amplitude = 32766
10071  nframes = len(data)
10072  comptype = "NONE"
10073  compname = "not compressed"
10074  wavfile.setparams((nchannels,
10075  sampwidth,
10076  framerate,
10077  nframes,
10078  comptype,
10079  compname))
10080  # Normalize data
10081  ArrN = numpy.array(data)
10082  ArrN /= numpy.max(numpy.abs(data))
10083  frames = []
10084  for s in ArrN:
10085  mul = int(s * amplitude)
10086  # print "s: %f mul: %d" % (s, mul)
10087  frames.append(struct.pack('h', mul))
10088  print( len(frames))
10089  frames = ''.join(frames)
10090  print( len(frames))
10091  for x in xrange(0, repeat):
10092  print( x )
10093  wavfile.writeframes(frames)
10094  wavfile.close()
10095 
10096 # =========== Awg functions ==================
10097 def BAWGAAmpl(temp):
10098  global AWGAAmplEntry, AWGAAmplvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10099  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10100 
10101  try:
10102  AWGAAmplvalue = float(eval(AWGAAmplEntry.get()))
10103  except:
10104  AWGAAmplEntry.delete(0,"end")
10105  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10106  #
10107  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10108  if AWGAMode.get() == 0: # Source Voltage measure current mode
10109  if AWGAAmplvalue > 5.00:
10110  AWGAAmplvalue = 5.00
10111  AWGAAmplEntry.delete(0,"end")
10112  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10113  if AWGAAmplvalue < 0.00:
10114  AWGAAmplvalue = 0.00
10115  AWGAAmplEntry.delete(0,"end")
10116  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10117  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10118  if AWGAMode.get() == 0: # Source Voltage measure current mode
10119  if AWGAAmplvalue > (2.5 / AWGA_Ext_Gain.get()):
10120  AWGAAmplvalue = 2.5 / AWGA_Ext_Gain.get()
10121  AWGAAmplEntry.delete(0,"end")
10122  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10123  if AWGAAmplvalue < (-2.50 / AWGA_Ext_Gain.get()):
10124  AWGAAmplvalue = -2.50 / AWGA_Ext_Gain.get()
10125  AWGAAmplEntry.delete(0,"end")
10126  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10127  if AWGAMode.get() == 1: # Source current measure voltage mode
10128  if AWGAAmplvalue > 200.00:
10129  AWGAAmplvalue = 200.00
10130  AWGAAmplEntry.delete(0,"end")
10131  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10132  if AWGAAmplvalue < -200.00:
10133  AWGAAmplvalue = -200.00
10134  AWGAAmplEntry.delete(0,"end")
10135  AWGAAmplEntry.insert(0, AWGAAmplvalue)
10136 #
10137 def BAWGAOffset(temp):
10138  global AWGAOffsetEntry, AWGAOffsetvalue, AWGAMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10139  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10140 
10141  try:
10142  AWGAOffsetvalue = float(eval(AWGAOffsetEntry.get()))
10143  except:
10144  AWGAOffsetEntry.delete(0,"end")
10145  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10146  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
10147  if AWGAMode.get() == 0: # Source Voltage measure current mode
10148  if AWGAOffsetvalue > 5.00:
10149  AWGAOffsetvalue = 5.00
10150  AWGAOffsetEntry.delete(0,"end")
10151  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10152  if AWGAOffsetvalue < 0.00:
10153  AWGAOffsetvalue = 0.00
10154  AWGAOffsetEntry.delete(0,"end")
10155  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10156  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
10157  if AWGAOffsetvalue > (2.50-AWGA_Ext_Offset.get()):
10158  AWGAOffsetvalue = 2.50-AWGA_Ext_Offset.get()
10159  AWGAOffsetEntry.delete(0,"end")
10160  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10161  if AWGAOffsetvalue < (-2.50-AWGA_Ext_Offset.get()):
10162  AWGAOffsetvalue = -2.50-AWGA_Ext_Offset.get()
10163  AWGAOffsetEntry.delete(0,"end")
10164  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10165  if AWGAMode.get() == 1: # Source current measure voltage mode
10166  if AWGAOffsetvalue > 200.00:
10167  AWGAOffsetvalue = 200.00
10168  AWGAOffsetEntry.delete(0,"end")
10169  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10170  if AWGAOffsetvalue < -200.00:
10171  AWGAOffsetvalue = -200.00
10172  AWGAOffsetEntry.delete(0,"end")
10173  AWGAOffsetEntry.insert(0, AWGAOffsetvalue)
10174 #
10175 def BAWGAFreq(temp):
10176  global AWGAFreqEntry, AWGAFreqvalue, AWG_2X
10177  global BodeScreenStatus, BodeDisp
10178 
10179  try:
10180  AWGAFreqvalue = float(eval(AWGAFreqEntry.get()))
10181  except:
10182  AWGAFreqEntry.delete(0,"end")
10183  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10184  if AWG_2X.get() == 1:
10185  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
10186  if AWGAFreqvalue > 90000: # max freq is 90KHz foe Bode Plots
10187  AWGAFreqvalue = 90000
10188  AWGAFreqEntry.delete(0,"end")
10189  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10190  else:
10191  if AWGAFreqvalue > 50000: # max freq is 50KHz
10192  AWGAFreqvalue = 50000
10193  AWGAFreqEntry.delete(0,"end")
10194  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10195  else:
10196  if AWGAFreqvalue > 25000: # max freq is 25KHz
10197  AWGAFreqvalue = 25000
10198  AWGAFreqEntry.delete(0,"end")
10199  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10200  if AWGAFreqvalue < 0: # Set negative frequency entry to 0
10201  AWGAFreqvalue = 10
10202  AWGAFreqEntry.delete(0,"end")
10203  AWGAFreqEntry.insert(0, AWGAFreqvalue)
10204  #UpdateAWGA()
10205 
10207  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10208 
10209  if AWGAPhaseDelay.get() == 1:
10210  AWGAPhaseDelay.set(0)
10211  awgaph.configure(text="Phase")
10212  phasealab.configure(text="Deg")
10213  elif AWGAPhaseDelay.get() == 0:
10214  AWGAPhaseDelay.set(1)
10215  awgaph.configure(text="Delay")
10216  phasealab.configure(text="mSec")
10217 
10219  global AWGAPhaseDelay, phasealab, awgaph, awgadel
10220 
10221  if AWGAPhaseDelay.get() == 0:
10222  phasealab.configure(text="Deg")
10223  awgaph.configure(text="Phase")
10224  elif AWGAPhaseDelay.get() == 1:
10225  phasealab.configure(text="mSec")
10226  awgaph.configure(text="Delay")
10227 
10228 def BAWGAPhase(temp):
10229  global AWGAPhaseEntry, AWGAPhasevalue
10230 
10231  try:
10232  AWGAPhasevalue = float(eval(AWGAPhaseEntry.get()))
10233  except:
10234  AWGAPhaseEntry.delete(0,"end")
10235  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10236 
10237  if AWGAPhasevalue > 360: # max phase is 360 degrees
10238  AWGAPhasevalue = 360
10239  AWGAPhaseEntry.delete(0,"end")
10240  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10241  if AWGAPhasevalue < 0: # min phase is 0 degrees
10242  AWGAPhasevalue = 0
10243  AWGAPhaseEntry.delete(0,"end")
10244  AWGAPhaseEntry.insert(0, AWGAPhasevalue)
10245 
10246 def BAWGADutyCycle(temp):
10247  global AWGADutyCycleEntry, AWGADutyCyclevalue
10248 
10249  try:
10250  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))/100
10251  except:
10252  AWGADutyCycleEntry.delete(0,"end")
10253  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10254 
10255  if AWGADutyCyclevalue > 1: # max duty cycle is 100%
10256  AWGADutyCyclevalue = 1
10257  AWGADutyCycleEntry.delete(0,"end")
10258  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue*100)
10259  if AWGADutyCyclevalue < 0: # min duty cycle is 0%
10260  AWGADutyCyclevalue = 0
10261  AWGADutyCycleEntry.delete(0,"end")
10262  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10263  #UpdateAWGA()
10264 
10266  global AWGAShape, AWGAWave, phasealab, duty1lab
10267 
10268  if AWGAShape.get() == 0:
10269  AWGAWave = 'dc'
10270  duty1lab.config(text="%")
10271  BAWGAPhaseDelay()
10272  if AWGAShape.get() == 1:
10273  AWGAWave = 'sine'
10274  duty1lab.config(text="%")
10275  BAWGAPhaseDelay()
10276  if AWGAShape.get() == 2:
10277  AWGAWave = 'triangle'
10278  duty1lab.config(text="%")
10279  BAWGAPhaseDelay()
10280  if AWGAShape.get() == 3:
10281  AWGAWave = 'sawtooth'
10282  duty1lab.config(text="%")
10283  BAWGAPhaseDelay()
10284  if AWGAShape.get() == 4:
10285  AWGAWave = 'square'
10286  duty1lab.config(text="%")
10287  BAWGAPhaseDelay()
10288  if AWGAShape.get() == 5:
10289  AWGAWave = 'stairstep'
10290  duty1lab.config(text="%")
10291  BAWGAPhaseDelay()
10292  if AWGAShape.get() > 5:
10293  AWGAWave = 'arbitrary'
10294  # UpdateAWGA()
10295 
10297  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile
10298 
10299  # Read values from CVS file
10300  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10301  AWGAcsvFile = filename
10302  AWGALoadCSV()
10303 #
10305  global AWGAwaveform, AWGALength, awgwindow, AWG_2X, AWGA2X, AWGAcsvFile
10306 
10307  try:
10308  CSVFile = open(AWGAcsvFile)
10309  # dialect = csv.Sniffer().sniff(CSVFile.read(128))
10310  CSVFile.seek(0)
10311  #csv_f = csv.reader(CSVFile, dialect)
10312  csv_f = csv.reader(CSVFile, csv.excel)
10313  except:
10314  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10315  # print csv_f.dialect
10316  AWGAwaveform = []
10317  ColumnNum = 0
10318  ColumnSel = 0
10319  RowNum = 0
10320  for row in csv_f:
10321  # print 'found row = ', row
10322  if len(row) > 1 and ColumnSel == 0:
10323  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
10324  ColumnNum = int(RequestColumn) - 1
10325  ColumnLen = str(len(row))
10326  ColumnSel = 1
10327  try:
10328  colnum = 0
10329  for col in row:
10330  if colnum == ColumnNum:
10331  AWGAwaveform.append(float(col))
10332  colnum += 1
10333  except:
10334  print( 'skipping non-numeric row', RowNum)
10335  RowNum += 1
10336  AWGAwaveform = numpy.array(AWGAwaveform)
10338  CSVFile.close()
10339  UpdateAwgCont()
10340 
10341 # Split 2X sampled AWGAwaveform array into odd and even sample arrays
10343  global AWG_2X, AWGA2X, AWGAwaveform
10344  global AWGFiltA, AWGFiltACoef
10345 
10346  # check if AWG digital filter box checked
10347  if AWGFiltA.get() == 1:
10348  BufLen = len(AWGAwaveform)
10349  CoefLen = len(AWGFiltACoef)/2
10350  AWGAwaveform = numpy.pad(AWGAwaveform, (CoefLen,CoefLen), 'wrap')
10351  AWGAwaveform = numpy.convolve(AWGAwaveform, AWGFiltACoef)
10352  AWGAwaveform = numpy.roll(AWGAwaveform, -CoefLen)
10353  AWGAwaveform = AWGAwaveform[CoefLen:BufLen+CoefLen]
10354 
10355  if AWG_2X.get() == 1:
10356  Tempwaveform = []
10357  AWGA2X = []
10358  AWGA2X = AWGAwaveform[1::2] # odd numbered samples
10359  Tempwaveform = AWGAwaveform[::2] # even numbered samples Tempwaveform
10360  AWGAwaveform = Tempwaveform
10361 #
10363  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10364 
10365  if AWGABurstFlag.get() == 1:
10366  AWGACyclesString = askstring("AWG A Burst Mode", "Current number of cycles " + str(AWGACycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGACycles), parent=awgwindow)
10367  if (AWGACyclesString == None): # If Cancel pressed, then None
10368  return
10369  AWGACycles = int(AWGACyclesString)
10370  AWGADelayString = askstring("AWG A Burst Mode", "Current Burst delay " + str(AWGABurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGABurstDelay), parent=awgwindow)
10371  if (AWGADelayString == None): # If Cancel pressed, then None
10372  return
10373  AWGABurstDelay = float(AWGADelayString)
10374  ReMakeAWGwaves()
10375 #
10377  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10378  global AWG_2X, AWGA2X, AWGAwavFile
10379 
10380 # Read values from WAV file
10381  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
10382  AWGAwavFile = filename
10383  AWGALoadWAV()
10384 #
10386  global AWGAwaveform, AWGALength, AWGAShape, awgwindow, AWGBwaveform, AWGBLength, AWGBShape
10387  global AWG_2X, AWGA2X, AWGAwavFile
10388 
10389  try:
10390  spf = wave.open(AWGAwavFile,'r')
10391  except:
10392  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
10393  AWGAwaveform = []
10394  AWGBwaveform = []
10395  Length = spf.getnframes()
10396  if Length > 90000:
10397  Length = 90000
10398  # If Stereo put first channel in AWGA and second channel in AWGB
10399  if spf.getnchannels() == 2:
10400  showwarning("Split Stereo","Left to AWGA Right to AWGB", parent=awgwindow)
10401  signal = spf.readframes(Length)
10402  Stereo = numpy.fromstring(signal, 'Int16') # convert strings to Int
10403  n = 0
10404  while n < Length*2:
10405  AWGAwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10406  n = n + 1
10407  AWGBwaveform.append((Stereo[n] * 2.5 / 32768) + 2.5)
10408  n = n + 1
10409  AWGAwaveform = numpy.array(AWGAwaveform)
10410  AWGBwaveform = numpy.array(AWGBwaveform)
10411  AWGBShape.set(AWGAShape.get())
10412  else:
10413  #Extract Raw Audio from Wav File
10414  signal = spf.readframes(Length)
10415  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
10416  # offset and scale for 0 5 V range
10417  AWGAwaveform = (WAVsignal * 2.5 / 32768) + 2.5
10418  AWGAwaveform = numpy.array(AWGAwaveform)
10420  spf.close()
10421  UpdateAwgCont()
10422 
10424  global AWGAwaveform, AWGALength, awgwindow
10425 
10426  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
10427  numpy.savetxt(filename, AWGAwaveform, delimiter=",", fmt='%2.4f')
10428 
10430  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10431  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10432  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10433  global DFiltACoef, DFiltBCoef, AWGAShapeLabel, AWGALength
10434  global AWG_2X, AWGA2X
10435 
10436  TempString = AWGAMathString
10437  AWGAShapeLabel.config(text = "Math" ) # change displayed value
10438  AWGAMathString = askstring("AWG A Math Formula", "Current Formula: " + AWGAMathString + "\n\nNew Formula:\n", initialvalue=AWGAMathString, parent=awgwindow)
10439  if (AWGAMathString == None): # If Cancel pressed, then None
10440  AWGAMathString = TempString
10441  return
10442  try:
10443  AWGAwaveform = eval(AWGAMathString)
10444  except:
10445  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
10446  AWGAwaveform = numpy.array(AWGAwaveform)
10448  AWGALength.config(text = "L = " + str(int(len(AWGAwaveform)))) # change displayed value
10449  UpdateAwgCont()
10450 #
10452  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
10453  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAMathString
10454  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGALength, awgwindow
10455  global DFiltACoef, DFiltBCoef, AWGAShapeLabel
10456  global AWG_2X, AWGA2X
10457 
10458  AWGAwaveform = eval(AWGAMathString)
10459  AWGAwaveform = numpy.array(AWGAwaveform)
10461  UpdateAwgCont()
10462 #
10464  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10465  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10466  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode, AWGRecLength
10467  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10468 
10469  BAWGAAmpl(0)
10470  BAWGAOffset(0)
10471  BAWGAFreq(0)
10472  BAWGAPhase(0)
10473  BAWGADutyCycle(0)
10474 
10475  if AWGAFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
10476  AWGAShape.set(1)
10477  BAWGAShape()
10478  UpdateAwgCont()
10479  return
10480 
10481  if AWGAFreqvalue > 0.0:
10482  if AWG_2X.get() == 1:
10483  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10484  else:
10485  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10486  else:
10487  AWGAperiodvalue = 10.0
10488 
10489  if AWGAPhaseDelay.get() == 0:
10490  if AWGAPhasevalue > 0:
10491  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10492  else:
10493  AWGAdelayvalue = 0.0
10494  elif AWGAPhaseDelay.get() == 1:
10495  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
10496  Cycles = int(AWGRecLength/AWGAperiodvalue)
10497  if Cycles < 1:
10498  Cycles = 1
10499  RecLength = int(Cycles * AWGAperiodvalue)
10500  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10501  RecLength = RecLength + 1
10502  AWGAwaveform = []
10503  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
10504 
10505  if AWG_Amp_Mode.get() == 0:
10506  if AWGAMode.get() == 1: # convert to mA
10507  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10508  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10509  else:
10510  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10511  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10512  else:
10513  if AWGAMode.get() == 1: # convert to mA
10514  amplitude = AWGAAmplvalue/1000.0
10515  offset = AWGAOffsetvalue/1000.0
10516  else:
10517  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10518  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10519  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10520  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10521 #
10523  BAWGAPhaseDelay()
10524  duty1lab.config(text="%")
10525  UpdateAwgCont()
10526 #
10528  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10529  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10530  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
10531  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
10532 
10533  BAWGAAmpl(0)
10534  BAWGAOffset(0)
10535  BAWGAFreq(0)
10536 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
10537  duty1lab.config(text = "M Index")
10538  phasealab.config(text = "M Freq")
10539 
10540  if AWGAFreqvalue > 0.0:
10541  if AWG_2X.get() == 1:
10542  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10543  else:
10544  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10545  else:
10546  AWGAperiodvalue = 10.0
10547 
10548  try:
10549  ModFreq = float(eval(AWGAPhaseEntry.get()))
10550  except:
10551  ModFreq = 10
10552  AWGAPhaseEntry.delete(0,"end")
10553  AWGAPhaseEntry.insert(0, ModFreq)
10554 
10555  if ModFreq < 10:
10556  ModFreq = 10
10557  AWGAPhaseEntry.delete(0,"end")
10558  AWGAPhaseEntry.insert(0, ModFreq)
10559 
10560  if AWG_2X.get() == 1:
10561  MODperiodvalue = (BaseSampleRate*2)/ModFreq
10562  else:
10563  MODperiodvalue = BaseSampleRate/ModFreq
10564 
10565  try:
10566  ModIndex = float(eval(AWGADutyCycleEntry.get()))
10567  except:
10568  ModIndex = 1.0
10569  AWGADutyCycleEntry.delete(0,"end")
10570  AWGADutyCycleEntry.insert(0, ModIndex)
10571 
10572  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
10573  if ModCycles < 1:
10574  ModCycles = 1
10575  RecLength = int(ModCycles * MODperiodvalue)
10576  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10577  RecLength = RecLength + 1
10578  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
10579  AWGAwaveform = []
10580  AWGAwaveform = numpy.sin( (numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) - ModIndex*numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)) )
10581  if AWG_Amp_Mode.get() == 0:
10582  if AWGAMode.get() == 1: # convert to mA
10583  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10584  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10585  else:
10586  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10587  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10588  else:
10589  if AWGAMode.get() == 1: # convert to mA
10590  amplitude = AWGAAmplvalue/1000.0
10591  offset = AWGAOffsetvalue/1000.0
10592  else:
10593  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10594  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10595  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10596  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10597 #
10598  SplitAWGAwaveform() # if needed
10599  UpdateAwgCont()
10600 #
10602  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10603  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay, AWGAMode
10604  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, phasealab, AWG_Amp_Mode
10605  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
10606 
10607  BAWGAAmpl(0)
10608  BAWGAOffset(0)
10609  BAWGAFreq(0)
10610 # uses dyty cycle entry for Modulation index and phase entry for Modulation frequency
10611  duty1lab.config(text = "M Index")
10612  phasealab.config(text = "M Freq")
10613 
10614  if AWGAFreqvalue > 0.0:
10615  if AWG_2X.get() == 1:
10616  AWGAperiodvalue = (BaseSampleRate*2)/AWGAFreqvalue
10617  else:
10618  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10619  else:
10620  AWGAperiodvalue = 10.0
10621 
10622  try:
10623  ModFreq = float(eval(AWGAPhaseEntry.get()))
10624  except:
10625  ModFreq = 10
10626  AWGAPhaseEntry.delete(0,"end")
10627  AWGAPhaseEntry.insert(0, ModFreq)
10628 
10629  if ModFreq < 10:
10630  ModFreq = 10
10631  AWGAPhaseEntry.delete(0,"end")
10632  AWGAPhaseEntry.insert(0, ModFreq)
10633 
10634  if AWG_2X.get() == 1:
10635  MODperiodvalue = (BaseSampleRate*2)/ModFreq
10636  else:
10637  MODperiodvalue = BaseSampleRate/ModFreq
10638 
10639  try:
10640  ModIndex = float(eval(AWGADutyCycleEntry.get()))/200.0
10641  except:
10642  ModIndex = 50.0
10643  AWGADutyCycleEntry.delete(0,"end")
10644  AWGADutyCycleEntry.insert(0, ModIndex)
10645 
10646  ModCycles = int(AWGRecLength/MODperiodvalue) # find a whole number of cycles
10647  if ModCycles < 1:
10648  ModCycles = 1
10649  RecLength = int(ModCycles * MODperiodvalue)
10650  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10651  RecLength = RecLength + 1
10652  CarCycles = int(RecLength/AWGAperiodvalue) # insure a whole number of carrier cycles in record
10653  AWGAwaveform = []
10654  AWGAwaveform = numpy.sin(numpy.linspace(0, CarCycles*2*numpy.pi, RecLength)) * (0.5+(ModIndex*(numpy.cos(numpy.linspace(0, ModCycles*2*numpy.pi, RecLength)))))
10655  if AWG_Amp_Mode.get() == 0:
10656  if AWGAMode.get() == 1: # convert to mA
10657  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2000.0
10658  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2000.0
10659  else:
10660  amplitude = (AWGAOffsetvalue-AWGAAmplvalue) / -2.0
10661  offset = (AWGAOffsetvalue+AWGAAmplvalue) / 2.0
10662  else:
10663  if AWGAMode.get() == 1: # convert to mA
10664  amplitude = AWGAAmplvalue/1000.0
10665  offset = AWGAOffsetvalue/1000.0
10666  else:
10667  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10668  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10669  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10670  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10671 #
10672  SplitAWGAwaveform() # if needed
10673  UpdateAwgCont()
10674 #
10676  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
10677  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10678  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10679  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10680 
10681  BAWGAAmpl(0)
10682  BAWGAOffset(0)
10683  BAWGAFreq(0)
10684  BAWGAPhase(0)
10685  BAWGADutyCycle(0)
10686 
10687  if AWGAFreqvalue > 0.0:
10688  if AWG_2X.get() == 1:
10689  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10690  else:
10691  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10692  else:
10693  AWGAperiodvalue = 0.0
10694  if AWG_Amp_Mode.get() == 1:
10695  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10696  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10697  else:
10698  MaxV = AWGAOffsetvalue
10699  MinV = AWGAAmplvalue
10700 
10701  PulseWidth = int(AWGADutyCyclevalue*100)
10702  PulseSamples = int(AWGAperiodvalue/PulseWidth)
10703  AWGAwaveform = []
10704  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
10705  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
10706  # print(v)
10707  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
10708  if j >= v:
10709  AWGAwaveform.append(MaxV) # j>=v?1:0
10710  else:
10711  AWGAwaveform.append(MinV) # j>=v?1:0
10713  duty1lab.config(text="PWidth")
10714  UpdateAwgCont()
10715 #
10717  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength
10718  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10719  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10720  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10721 
10722  BAWGAAmpl(0)
10723  BAWGAOffset(0)
10724  BAWGAFreq(0)
10725  BAWGADutyCycle(0)
10726 
10727  Max_term = int(AWGADutyCyclevalue*100)
10728  if AWG_2X.get() == 1:
10729  TempRate = (BaseSampleRate*2)
10730  else:
10731  TempRate = BaseSampleRate
10732  AWGAwaveform = []
10733  AWGAwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGAFreqvalue))) # the fundamental
10734  k = 3
10735  while k <= Max_term:
10736  # Add odd harmonics up to max_term
10737  Harmonic = (math.sin(k*numpy.pi/2.0)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGAFreqvalue))))
10738  AWGAwaveform = AWGAwaveform + Harmonic
10739  k = k + 2 # skip even numbers
10740  if AWG_Amp_Mode.get() == 0:
10741  amplitude = (AWGAOffsetvalue-AWGAAmplvalue)/2.0
10742  offset = (AWGAOffsetvalue+AWGAAmplvalue)/2.0
10743  else:
10744  amplitude = AWGAAmplvalue*AWGA_Ext_Gain.get()
10745  offset = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get()
10746  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10748  duty1lab.config(text="Harmonics")
10749  BAWGAPhaseDelay()
10750  UpdateAwgCont()
10751 #
10753  global AWGAwaveform, AWGSampleRate, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAperiodvalue
10754  global AWGADutyCyclevalue, AWGAFreqvalue, duty1lab, AWGAgain, AWGAoffset, AWGAPhaseDelay
10755  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10756  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10757 
10758  BAWGAAmpl(0)
10759  BAWGAOffset(0)
10760  BAWGAFreq(0)
10761  BAWGAPhase(0)
10762  BAWGADutyCycle(0)
10763 
10764  if AWGAFreqvalue > 0.0:
10765  if AWG_2X.get() == 1:
10766  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10767  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10768  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10769  AWGAperiodvalue = AWGAperiodvalue + 1
10770  else:
10771  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10772  SamplesPermS = int(BaseSampleRate/1000) # 100
10773  else:
10774  AWGAperiodvalue = 0.0
10775  if AWG_Amp_Mode.get() == 1:
10776  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10777  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10778  else:
10779  MaxV = AWGAOffsetvalue
10780  MinV = AWGAAmplvalue
10781 
10782  if AWGAPhaseDelay.get() == 0:
10783  if AWGAPhasevalue > 0:
10784  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
10785  else:
10786  AWGAdelayvalue = 0.0
10787  elif AWGAPhaseDelay.get() == 1:
10788  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
10789 
10790  Cycles = int(AWGADutyCyclevalue*100)
10791  NCycles = -1 * Cycles
10792  AWGAwaveform = []
10793  AWGAwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGAFreqvalue)))
10794  amplitude = (MaxV-MinV) / 2.0
10795  offset = (MaxV+MinV) / 2.0
10796  AWGAwaveform = (AWGAwaveform * amplitude) + offset # scale and offset the waveform
10797  Cycles = int(37500/AWGAperiodvalue)
10798  if Cycles < 1:
10799  Cycles = 1
10800  if Cycles > 1:
10801  Extend = int((Cycles-1.0)*AWGAperiodvalue/2.0)
10802  AWGAwaveform = numpy.pad(AWGAwaveform, (Extend,Extend), 'wrap')
10803  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
10805  #BAWGAPhaseDelay()
10806  duty1lab.config(text="Cycles")
10807  BAWGAPhaseDelay()
10808  UpdateAwgCont()
10809 #
10811  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10812  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10813  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10814  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10815  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10816 
10817  BAWGAAmpl(0)
10818  BAWGAOffset(0)
10819  BAWGAFreq(0)
10820  BAWGAPhase(0)
10821  BAWGADutyCycle(0)
10822 
10823  if AWGAFreqvalue > 0.0:
10824  if AWG_2X.get() == 1:
10825  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10826  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10827  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10828  AWGAperiodvalue = AWGAperiodvalue + 1
10829  else:
10830  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10831  SamplesPermS = int(BaseSampleRate/1000) # 100
10832  else:
10833  AWGAperiodvalue = 0.0
10834  if AWG_Amp_Mode.get() == 1:
10835  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10836  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10837  else:
10838  MaxV = AWGAOffsetvalue
10839  MinV = AWGAAmplvalue
10840  AWGAwaveform = []
10841  SlopeValue = int(AWGAPhasevalue*SamplesPermS)
10842  if SlopeValue <= 0:
10843  SlopeValue = 1
10844  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
10845  if PulseWidth <=0:
10846  PulseWidth = 1
10847  Remainder = int((AWGAperiodvalue - PulseWidth - SlopeValue)/2)
10848  if Remainder <= 0:
10849  Remainder = 1
10850  PulseWidth = PulseWidth - SlopeValue
10851  if PulseWidth <=0:
10852  PulseWidth = 1
10853  StepAmp = (MaxV - MinV)/2
10854  StepOff = (MaxV + MinV)/2
10855  AWGAwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
10856  MidArray = numpy.ones(PulseWidth) * MinV
10857  AWGAwaveform = numpy.insert(AWGAwaveform, SlopeValue, MidArray)
10858  AWGAwaveform = numpy.pad(AWGAwaveform, (Remainder, Remainder), 'edge')
10859  if AWGABurstFlag.get() == 1:
10860  TempOneCycle = AWGAwaveform
10861  for i in range(AWGACycles-1):
10862  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
10863  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
10864  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
10866  duty1lab.config(text="%")
10867  phasealab.config(text = "Rise Time")
10868  UpdateAwgCont()
10869 #
10871  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10872  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10873  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10874  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10875  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10876 
10877  BAWGAAmpl(0)
10878  BAWGAOffset(0)
10879  BAWGAFreq(0)
10880  BAWGAPhase(0)
10881  BAWGADutyCycle(0)
10882 
10883  if AWGAFreqvalue > 0.0:
10884  if AWG_2X.get() == 1:
10885  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10886  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10887  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10888  AWGAperiodvalue = AWGAperiodvalue + 1
10889  else:
10890  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10891  SamplesPermS = int(BaseSampleRate/1000) # 100
10892  else:
10893  AWGAperiodvalue = 0.0
10894  if AWG_Amp_Mode.get() == 1:
10895  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10896  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10897  else:
10898  MaxV = AWGAOffsetvalue
10899  MinV = AWGAAmplvalue
10900  AWGAwaveform = []
10901  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
10902  if SlopeValue <= 0:
10903  SlopeValue = 1
10904  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
10905  if PulseWidth <=0:
10906  PulseWidth = 1
10907  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
10908  if Remainder <= 0:
10909  Remainder = 1
10910  PulseWidth = PulseWidth - SlopeValue
10911  if PulseWidth <=0:
10912  PulseWidth = 1
10913  StepValue = (MaxV - MinV) / SlopeValue
10914  SampleValue = MinV
10915  for i in range(SlopeValue):
10916  AWGAwaveform.append(SampleValue)
10917  SampleValue = SampleValue + StepValue
10918  for i in range(PulseWidth):
10919  AWGAwaveform.append(MaxV)
10920  for i in range(SlopeValue):
10921  AWGAwaveform.append(SampleValue)
10922  SampleValue = SampleValue - StepValue
10923  for i in range(Remainder):
10924  AWGAwaveform.append(MinV)
10925  if AWGABurstFlag.get() == 1:
10926  TempOneCycle = AWGAwaveform
10927  for i in range(AWGACycles-1):
10928  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
10929  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
10930  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
10932  duty1lab.config(text="%")
10933  phasealab.config(text = "Rise Time")
10934  UpdateAwgCont()
10935 #
10937  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
10938  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
10939  global AWGABurstFlag, AWGACycles, AWGABurstDelay
10940  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
10941  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
10942 
10943  BAWGAAmpl(0)
10944  BAWGAOffset(0)
10945  BAWGAFreq(0)
10946  BAWGAPhase(0)
10947 
10948  try:
10949  AWGADutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
10950  except:
10951  AWGADutyCycleEntry.delete(0,"end")
10952  AWGADutyCycleEntry.insert(0, AWGADutyCyclevalue)
10953 
10954  if AWGAFreqvalue > 0.0:
10955  if AWG_2X.get() == 1:
10956  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
10957  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
10958  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
10959  AWGAperiodvalue = AWGAperiodvalue + 1
10960  else:
10961  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
10962  SamplesPermS = int(BaseSampleRate/1000) # 100
10963  else:
10964  AWGAperiodvalue = 0.0
10965  if AWG_Amp_Mode.get() == 1:
10966  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
10967  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
10968  else:
10969  MaxV = AWGAOffsetvalue
10970  MinV = AWGAAmplvalue
10971  AWGAwaveform = []
10972  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
10973  if SlopeValue <= 0:
10974  SlopeValue = 1
10975  PulseWidth = int(AWGADutyCyclevalue*SamplesPermS) # convert mS to samples
10976  if PulseWidth <=0:
10977  PulseWidth = 1
10978  Remainder = int(AWGAperiodvalue - PulseWidth) - SlopeValue
10979  if Remainder <= 0:
10980  Remainder = 1
10981  PulseWidth = PulseWidth - SlopeValue
10982  if PulseWidth <=0:
10983  PulseWidth = 1
10984  StepValue = (MaxV - MinV) / SlopeValue
10985  SampleValue = MinV
10986  for i in range(SlopeValue):
10987  AWGAwaveform.append(SampleValue)
10988  SampleValue = SampleValue + StepValue
10989  for i in range(PulseWidth):
10990  AWGAwaveform.append(MaxV)
10991  for i in range(SlopeValue):
10992  AWGAwaveform.append(SampleValue)
10993  SampleValue = SampleValue - StepValue
10994  for i in range(Remainder):
10995  AWGAwaveform.append(MinV)
10996  if AWGABurstFlag.get() == 1:
10997  TempOneCycle = AWGAwaveform
10998  for i in range(AWGACycles-1):
10999  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11000  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11001  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11003  duty1lab.config(text="Width mS")
11004  phasealab.config(text = "Rise Time")
11005  UpdateAwgCont()
11006 #
11008  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, phasealab, duty1lab
11009  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11010  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11011  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11012  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11013 
11014  BAWGAAmpl(0)
11015  BAWGAOffset(0)
11016  BAWGAFreq(0)
11017  BAWGAPhase(0)
11018  BAWGADutyCycle(0)
11019 
11020  if AWGAFreqvalue > 0.0:
11021  if AWG_2X.get() == 1:
11022  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11023  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11024  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11025  AWGAperiodvalue = AWGAperiodvalue + 1
11026  else:
11027  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11028  SamplesPermS = int(BaseSampleRate/1000) # 100
11029  else:
11030  AWGAperiodvalue = 0.0
11031  if AWG_Amp_Mode.get() == 1:
11032  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11033  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11034  else:
11035  MaxV = AWGAOffsetvalue
11036  MinV = AWGAAmplvalue
11037  AWGAwaveform = []
11038  SlopeValue = int(AWGAPhasevalue*SamplesPermS) # convert mS to samples
11039  if SlopeValue <= 0:
11040  SlopeValue = 1
11041  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11042  if PulseWidth <=0:
11043  PulseWidth = 1
11044  Remainder = int(AWGAperiodvalue - PulseWidth)
11045  if Remainder <= 0:
11046  Remainder = 1
11047  PulseWidth = PulseWidth - SlopeValue
11048  if PulseWidth <=0:
11049  PulseWidth = 1
11050  StepValue = (MaxV - MinV) / SlopeValue
11051  SampleValue = MinV
11052  for i in range(SlopeValue):
11053  AWGAwaveform.append(SampleValue)
11054  SampleValue = SampleValue + StepValue
11055  for i in range(PulseWidth):
11056  AWGAwaveform.append(MaxV)
11057  for i in range(Remainder):
11058  AWGAwaveform.append(MinV)
11059  if AWGABurstFlag.get() == 1:
11060  TempOneCycle = AWGAwaveform
11061  for i in range(AWGACycles-1):
11062  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11063  TempDelay = int(AWGABurstDelay*SamplesPermS/2) # convert mS to samples
11064  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, TempDelay), 'edge')
11066  duty1lab.config(text="%")
11067  phasealab.config(text = "Slope Time")
11068  UpdateAwgCont()
11069 #
11071  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, duty1lab
11072  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11073  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11074  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11075  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11076 
11077  BAWGAAmpl(0)
11078  BAWGAOffset(0)
11079  BAWGAFreq(0)
11080  BAWGAPhase(0)
11081  BAWGADutyCycle(0)
11082 
11083  if AWGAFreqvalue > 0.0:
11084  if AWG_2X.get() == 1:
11085  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11086  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11087  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11088  AWGAperiodvalue = AWGAperiodvalue + 1
11089  else:
11090  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11091  SamplesPermS = int(BaseSampleRate/1000) # 100
11092  else:
11093  AWGAperiodvalue = 0.0
11094  if AWG_Amp_Mode.get() == 1:
11095  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11096  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11097  else:
11098  MaxV = AWGAOffsetvalue
11099  MinV = AWGAAmplvalue
11100  #
11101  if AWGAPhaseDelay.get() == 0:
11102  if AWGAPhasevalue > 0:
11103  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11104  else:
11105  AWGAdelayvalue = 0.0
11106  elif AWGAPhaseDelay.get() == 1:
11107  AWGAdelayvalue = AWGAPhasevalue * SAMPLErate / 1000
11108  #
11109  AWGAwaveform = []
11110  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue)
11111  if PulseWidth <=0:
11112  PulseWidth = 1
11113  Remainder = int(AWGAperiodvalue - PulseWidth)
11114  if Remainder <= 0:
11115  Remainder = 1
11116  UpStepValue = (MaxV - MinV) / PulseWidth
11117  DownStepValue = (MaxV - MinV) / Remainder
11118  SampleValue = MinV
11119  for i in range(PulseWidth):
11120  AWGAwaveform.append(SampleValue)
11121  SampleValue = SampleValue + UpStepValue
11122  for i in range(Remainder):
11123  AWGAwaveform.append(SampleValue)
11124  SampleValue = SampleValue - DownStepValue
11125  AWGAwaveform = numpy.roll(AWGAwaveform, int(AWGAdelayvalue))
11126  if AWGABurstFlag.get() == 1:
11127  TempOneCycle = AWGAwaveform
11128  for i in range(AWGACycles-1):
11129  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11130  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11131  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11133  BAWGAPhaseDelay()
11134  duty1lab.config(text = "Symmetry")
11135  BAWGAPhaseDelay()
11136  UpdateAwgCont()
11137 #
11139  global AWGAwaveform, AWGAAmplvalue, AWGAOffsetvalue, AWGALength, AWGAPhaseDelay, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11140  global AWGAFreqvalue, AWGAperiodvalue, AWGSAMPLErate, AWGADutyCyclevalue, AWGAPhasevalue
11141  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11142  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11143  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11144 
11145  BAWGAAmpl(0)
11146  BAWGAOffset(0)
11147  BAWGAFreq(0)
11148  BAWGAPhase(0)
11149  BAWGADutyCycle(0)
11150 
11151  if AWGAFreqvalue > 0.0:
11152  if AWG_2X.get() == 1:
11153  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11154  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11155  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11156  AWGAperiodvalue = AWGAperiodvalue + 1
11157  else:
11158  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11159  SamplesPermS = int(BaseSampleRate/1000) # 100
11160  else:
11161  AWGAperiodvalue = 0.0
11162  if AWG_Amp_Mode.get() == 1:
11163  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11164  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11165  else:
11166  MaxV = AWGAOffsetvalue
11167  MinV = AWGAAmplvalue
11168  AWGAwaveform = []
11169  PulseWidth = int(AWGAperiodvalue * AWGADutyCyclevalue / 2.0)
11170  if AWGAPhaseDelay.get() == 0:
11171  DelayValue = int(AWGAperiodvalue*(AWGAPhasevalue/360))
11172  elif AWGAPhaseDelay.get() == 1:
11173  DelayValue = int(AWGAPhasevalue*SamplesPermS)
11174  for i in range(DelayValue-PulseWidth):
11175  AWGAwaveform.append((MinV+MaxV)/2.0)
11176  for i in range(PulseWidth):
11177  AWGAwaveform.append(MaxV)
11178  for i in range(PulseWidth):
11179  AWGAwaveform.append(MinV)
11180  DelayValue = int(AWGAperiodvalue-DelayValue)
11181  for i in range(DelayValue-PulseWidth):
11182  AWGAwaveform.append((MinV+MaxV)/2.0)
11183  if AWGABurstFlag.get() == 1:
11184  TempOneCycle = AWGAwaveform
11185  for i in range(AWGACycles-1):
11186  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11187  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11188  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'edge')
11190  duty1lab.config(text = "Duty Cycle")
11191  BAWGAPhaseDelay()
11192  UpdateAwgCont()
11193 
11195  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11196  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11197  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11198  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11199  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11200 
11201  BAWGAAmpl(0)
11202  BAWGAOffset(0)
11203  BAWGAFreq(0)
11204 
11205  if AWGAFreqvalue > 0.0:
11206  if AWG_2X.get() == 1:
11207  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11208  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11209  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11210  AWGAperiodvalue = AWGAperiodvalue + 1
11211  else:
11212  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11213  SamplesPermS = int(BaseSampleRate/1000) # 100
11214  else:
11215  AWGAperiodvalue = 0.0
11216  if AWG_Amp_Mode.get() == 1:
11217  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11218  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11219  else:
11220  if AWGAAmplvalue > AWGAOffsetvalue:
11221  MinV = AWGAOffsetvalue
11222  MaxV = AWGAAmplvalue
11223  else:
11224  MaxV = AWGAOffsetvalue
11225  MinV = AWGAAmplvalue
11226  AWGAwaveform = []
11227  AWGAwaveform = numpy.random.uniform(MinV, MaxV, int(AWGAperiodvalue))
11228  Mid = (MaxV+MinV)/2.0
11229  if AWGABurstFlag.get() == 1:
11230  TempOneCycle = AWGAwaveform
11231  for i in range(AWGACycles-1):
11232  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11233  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11234  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11236  BAWGAPhaseDelay()
11237  UpdateAwgCont()
11238 
11240  global AWGAwaveform, AWGSAMPLErate, AWGAAmplvalue, AWGAOffsetvalue, AWGAFreqvalue
11241  global AWGALength, AWGAperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11242  global AWGABurstFlag, AWGACycles, AWGABurstDelay
11243  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate
11244  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11245 
11246  BAWGAAmpl(0)
11247  BAWGAOffset(0)
11248  BAWGAFreq(0)
11249 
11250  if AWGAFreqvalue > 0.0:
11251  if AWG_2X.get() == 1:
11252  AWGAperiodvalue = int((BaseSampleRate*2)/AWGAFreqvalue)
11253  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
11254  if AWGAperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11255  AWGAperiodvalue = AWGAperiodvalue + 1
11256  else:
11257  AWGAperiodvalue = BaseSampleRate/AWGAFreqvalue
11258  SamplesPermS = int(BaseSampleRate/1000) # 100
11259  else:
11260  AWGAperiodvalue = 0.0
11261  if AWG_Amp_Mode.get() == 1:
11262  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11263  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11264  else:
11265  if AWGAAmplvalue > AWGAOffsetvalue:
11266  MinV = AWGAOffsetvalue
11267  MaxV = AWGAAmplvalue
11268  else:
11269  MaxV = AWGAOffsetvalue
11270  MinV = AWGAAmplvalue
11271  AWGAwaveform = []
11272  AWGAwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGAperiodvalue))
11273  Mid = (MaxV+MinV)/2.0
11274  if AWGABurstFlag.get() == 1:
11275  TempOneCycle = AWGAwaveform
11276  for i in range(AWGACycles-1):
11277  AWGAwaveform = numpy.concatenate((AWGAwaveform, TempOneCycle))
11278  TempDelay = int(AWGABurstDelay*SamplesPermS) # convert mS to samples
11279  AWGAwaveform = numpy.pad(AWGAwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
11281  BAWGAPhaseDelay()
11282  UpdateAwgCont()
11283 
11285  global AWGAMode, AWGAIOMode, AWGAModeLabel, DevID, session, devx, DevOne, CHA, HWRevOne
11286  global EnableScopeOnly, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11287 
11288  if AWGAMode.get() == 0: # Source Voltage measure current mode
11289  label_txt = "SVMI"
11290  elif AWGAMode.get() == 1: # Source current measure voltage mode
11291  label_txt = "SIMV"
11292  elif AWGAMode.get() == 2: # High impedance mode
11293  label_txt = "Hi-Z"
11294  if AWGAIOMode.get() > 0: # Split Input / Output mode
11295  if HWRevOne == "D":
11296  if AWGAMode.get() == 0:
11297  AWGAMode.set(1)
11298  CHA.set_mode('i') # channel must be in source current mode for rev D boards
11299  label_txt = "SIMV"
11300  label_txt = label_txt + " Split I/O"
11301  if EnableScopeOnly == 0:
11302  label_txt = label_txt + " Mode"
11303  AWGAModeLabel.config(text = label_txt ) # change displayed value
11304  ReMakeAWGwaves()
11305  #UpdateAwgCont()
11306 
11308  global AWGAAmplvalue, AWGAOffsetvalue, EnableScopeOnly
11309  global AWGAFreqvalue, AWGAPhasevalue, AWGAPhaseDelay
11310  global AWGADutyCyclevalue, FSweepMode, AWGARepeatFlag, AWGSync
11311  global AWGAWave, AWGAMode, AWGATerm, AWGAwaveform, AWGAIOMode
11312  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11313  global amp1lab, off1lab, AWGA2X, AWGA2X, AWGBWave, AWGBRepeatFlag
11314  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11315 
11316  BAWGAAmpl(0)
11317  BAWGAOffset(0)
11318  BAWGAFreq(0)
11319  BAWGAPhase(0)
11320  BAWGADutyCycle(0)
11321  BAWGAShape()
11322 
11323  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
11324  amp1lab.config(text = "Min Ch A" ) # change displayed value
11325  off1lab.config(text = "Max Ch A" ) # change displayed value
11326  else:
11327  amp1lab.config(text = "Amp Ch A" )
11328  off1lab.config(text = "Off Ch A" )
11329 
11330  if AWGAFreqvalue > 0.0:
11331  AWGAperiodvalue = AWGSAMPLErate/AWGAFreqvalue
11332  else:
11333  AWGAperiodvalue = 0.0
11334 
11335  if AWGAPhaseDelay.get() == 0:
11336  if AWGAWave == 'square':
11337  AWGAPhasevalue = AWGAPhasevalue + 270.0
11338  if AWGAPhasevalue > 359:
11339  AWGAPhasevalue = AWGAPhasevalue - 360
11340  if AWGAPhasevalue > 0:
11341  AWGAdelayvalue = AWGAperiodvalue * AWGAPhasevalue / 360.0
11342  else:
11343  AWGAdelayvalue = 0.0
11344  elif AWGAPhaseDelay.get() == 1:
11345  AWGAdelayvalue = AWGAPhasevalue * 100
11346 
11347  if AWGATerm.get() == 0: # Open termination
11348  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11349  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11350  elif AWGATerm.get() == 1: # 50 Ohm termination to GND
11351  devx.ctrl_transfer( 0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
11352  devx.ctrl_transfer( 0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
11353  elif AWGATerm.get() == 2: # 50 Ohm termination to +2.5 Volts
11354  devx.ctrl_transfer( 0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
11355  devx.ctrl_transfer( 0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
11356 
11357  if AWGAWave == 'dc':
11358  if AWG_2X.get() == 2:
11359  AWGAWave == 'arbitrary'
11360  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
11361  else:
11362  if AWGAMode.get() == 0: # Source Voltage measure current mode
11363  if AWGAIOMode.get() == 0:
11364  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
11365  else:
11366  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
11367  CHA.constant(AWGAOffsetvalue)
11368  #
11369  if AWGAMode.get() == 1: # Source current measure voltage mode
11370  if AWGAIOMode.get() == 0:
11371  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
11372  else:
11373  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
11374  CHA.constant(AWGAOffsetvalue/1000)
11375  #
11376  if AWGAMode.get() == 2: # High impedance mode
11377  if AWGAIOMode.get() == 0:
11378  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
11379  else:
11380  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11381  #
11382  if AWGAIOMode.get() > 0: # Split Input / Output mode
11383  if HWRevOne == "D":
11384  AWGAMode.set(1)
11385  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11386 #
11387  else:
11388  if AWGAMode.get() == 0: # Source Voltage measure current mode
11389  if AWGAIOMode.get() == 0:
11390  CHA.mode = Mode.SVMI # Put CHA in SVMI mode
11391  else:
11392  CHA.mode = Mode.SVMI_SPLIT # Put CHA in SVMI split mode
11393  if AWGAMode.get() == 1: # Source current measure voltage mode
11394  if AWGAIOMode.get() == 0:
11395  CHA.mode = Mode.SIMV # Put CHA in SIMV mode
11396  else:
11397  CHA.mode = Mode.SIMV_SPLIT # Put CHA in SIMV split mode
11398  AWGAOffsetvalue = AWGAOffsetvalue/1000
11399  AWGAAmplvalue = AWGAAmplvalue/1000
11400  if AWGAMode.get() == 2: # High impedance mode
11401  if AWGAIOMode.get() == 0:
11402  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
11403  else:
11404  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
11405  else:
11406  if AWG_Amp_Mode.get() == 1:
11407  MaxV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() + (AWGAAmplvalue * AWGA_Ext_Gain.get())
11408  MinV = (AWGAOffsetvalue * AWGA_Ext_Gain.get()) + AWGA_Ext_Offset.get() - (AWGAAmplvalue * AWGA_Ext_Gain.get())
11409  else:
11410  MaxV = AWGAOffsetvalue
11411  MinV = AWGAAmplvalue
11412  try:
11413  if AWGAWave == 'sine':
11414  CHA.sine(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11415  elif AWGAWave == 'triangle':
11416  CHA.triangle(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11417  elif AWGAWave == 'sawtooth':
11418  CHA.sawtooth(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11419  elif AWGAWave == 'square':
11420  CHA.square(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue, AWGADutyCyclevalue)
11421  elif AWGAWave == 'stairstep':
11422  CHA.stairstep(MaxV, MinV, AWGAperiodvalue, AWGAdelayvalue)
11423  elif AWGAWave == 'arbitrary':
11424  if EnableScopeOnly == 0:
11425  AddAWGANoise()
11426  if AWGSync.get() == 0:
11427  AWGARepeatFlag.set(1)
11428  if AWG_2X.get() == 2:
11429  AWGAWave == 'arbitrary'
11430  CHA.arbitrary(AWGB2X, AWGBRepeatFlag.get())
11431  else:
11432  CHA.arbitrary(AWGAwaveform, AWGARepeatFlag.get()) # set repeat flag
11433  except:
11434  donothing()
11435  if AWGAIOMode.get() > 0: # Split Input / Output mode
11436  if HWRevOne == "D":
11437  AWGAMode.set(1)
11438  CHA.mode = Mode.SIMV_SPLIT # channel must be in source current mode
11439 #
11441  global AWG_2X, AWGB2X, AWGAwaveform
11442  global AWGANoiseEntry, AWGAsbnoise, AWGANoisevalue
11443 
11444  if AWGAsbnoise.get() == "None":
11445  return
11446  else:
11447  try:
11448  AWGANoisevalue = float(eval(AWGANoiseEntry.get()))
11449  except:
11450  AWGANoiseEntry.delete(0,"end")
11451  AWGANoiseEntry.insert(0, AWGANoisevalue)
11452  if AWGANoisevalue == 0.0:
11453  return
11454  AWGANoiseform = []
11455  if AWGAsbnoise.get() == "Gaussian":
11456  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGAwaveform))
11457  else:
11458  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGAwaveform))
11459  AWGAwaveform = AWGAwaveform + AWGANoiseform
11460  if AWG_2X.get() == 2:
11461  if AWGAsbnoise.get() == "Gaussian":
11462  AWGANoiseform = numpy.random.normal(0.0, abs((AWGANoisevalue)/3), len(AWGB2X))
11463  else:
11464  AWGANoiseform = numpy.random.uniform((-AWGANoisevalue)/2, (AWGANoisevalue)/2, len(AWGB2X))
11465  AWGB2X = AWGB2X + AWGANoiseform
11466 
11468  global AWGAAmplEntry, AWGBAmplEntry, AWGAOffsetEntry, AWGBOffsetEntry, AWGAFreqEntry, AWGBFreqEntry
11469  global AWGAPhaseEntry, AWGBPhaseEntry, AWGADutyCycleEntry, AWGBDutyCycleEntry, AWGAShape, AWGBShape
11470  global BisCompA, AWGAWave
11471 
11472  # if BisCompA.get() == 1:
11473  # sawp Min and Max values
11474  if AWGAWave == 'dc':
11475  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
11476  AWGBOffsetvalue = 2.5 - (float(eval(AWGAOffsetEntry.get()))-2.5)
11477  AWGBAmplEntry.delete(0,"end")
11478  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11479  AWGBOffsetEntry.delete(0,"end")
11480  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11481  else:
11482  AWGBAmplvalue = float(eval(AWGAAmplEntry.get()))
11483  AWGBOffsetvalue = float(eval(AWGAOffsetEntry.get()))
11484  AWGBAmplEntry.delete(0,"end")
11485  AWGBAmplEntry.insert(0, AWGBOffsetvalue)
11486  AWGBOffsetEntry.delete(0,"end")
11487  AWGBOffsetEntry.insert(0, AWGBAmplvalue)
11488  # copy everything else
11489  AWGBFreqvalue = float(eval(AWGAFreqEntry.get()))
11490  AWGBFreqEntry.delete(0,"end")
11491  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11492  AWGBPhasevalue = float(eval(AWGAPhaseEntry.get()))
11493  AWGBPhaseEntry.delete(0,"end")
11494  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11495  AWGBDutyCyclevalue = float(eval(AWGADutyCycleEntry.get()))
11496  AWGBDutyCycleEntry.delete(0,"end")
11497  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11498  AWGBShape.set(AWGAShape.get())
11499  #
11500 # ReMakeAWGwaves()
11501 # UpdateAwgCont()
11502 #
11503 # AWG B functions
11505  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
11506 
11507  if AWGBBurstFlag.get() == 1:
11508  AWGBCyclesString = askstring("AWG B Burst Mode", "Current number of cycles " + str(AWGBCycles) + "\n\nNew number of cycles:\n", initialvalue=str(AWGBCycles), parent=awgwindow)
11509  if (AWGBCyclesString == None): # If Cancel pressed, then None
11510  return
11511  AWGBCycles = int(AWGBCyclesString)
11512  AWGBDelayString = askstring("AWG B Burst Mode", "Current Burst delay " + str(AWGBBurstDelay) + "\n\nNew burst delay in mS:\n", initialvalue=str(AWGBBurstDelay), parent=awgwindow)
11513  if (AWGBDelayString == None): # If Cancel pressed, then None
11514  return
11515  AWGBBurstDelay = float(AWGBDelayString)
11516  ReMakeAWGwaves()
11517 #
11518 def BAWGBAmpl(temp):
11519  global AWGBAmplEntry, AWGBAmplvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11520  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11521 
11522  try:
11523  AWGBAmplvalue = float(eval(AWGBAmplEntry.get()))
11524  except:
11525  AWGBAmplEntry.delete(0,"end")
11526  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11527  #
11528  if AWGBMode.get() == 0: # Source Voltage measure current mode
11529  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max
11530  if AWGBAmplvalue > 5.00:
11531  AWGBAmplvalue = 5.00
11532  AWGBAmplEntry.delete(0,"end")
11533  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11534  if AWGBAmplvalue < 0.00:
11535  AWGBAmplvalue = 0.00
11536  AWGBAmplEntry.delete(0,"end")
11537  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11538  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
11539  if AWGBAmplvalue > (2.5 / AWGB_Ext_Gain.get()):
11540  AWGBAmplvalue = 2.5 / AWGB_Ext_Gain.get()
11541  AWGBAmplEntry.delete(0,"end")
11542  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11543  if AWGBAmplvalue < (-2.50 / AWGB_Ext_Gain.get()):
11544  AWGBAmplvalue = -2.50 / AWGB_Ext_Gain.get()
11545  AWGBAmplEntry.delete(0,"end")
11546  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11547  elif AWGBMode.get() == 1: # Source current measure voltage mode
11548  if AWGBAmplvalue > 200.00:
11549  AWGBAmplvalue = 200.00
11550  AWGBAmplEntry.delete(0,"end")
11551  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11552  if AWGBAmplvalue < -200.00:
11553  AWGBAmplvalue = -200.00
11554  AWGBAmplEntry.delete(0,"end")
11555  AWGBAmplEntry.insert(0, AWGBAmplvalue)
11556 #
11557 def BAWGBOffset(temp):
11558  global AWGBOffsetEntry, AWGBOffsetvalue, AWGBMode, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11559  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11560 
11561  try:
11562  AWGBOffsetvalue = float(eval(AWGBOffsetEntry.get()))
11563  except:
11564  AWGBOffsetEntry.delete(0,"end")
11565  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11566  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode
11567  if AWGBMode.get() == 0: # Source Voltage measure current mode
11568  if AWGBOffsetvalue > 5.00:
11569  AWGBOffsetvalue = 5.00
11570  AWGBOffsetEntry.delete(0,"end")
11571  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11572  if AWGBOffsetvalue < 0.00:
11573  AWGBOffsetvalue = 0.00
11574  AWGBOffsetEntry.delete(0,"end")
11575  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11576  elif AWG_Amp_Mode.get() == 1: # 1 = Amp/Offset
11577  if AWGBOffsetvalue > (2.50-AWGB_Ext_Offset.get()):
11578  AWGBOffsetvalue = 2.50-AWGB_Ext_Offset.get()
11579  AWGBOffsetEntry.delete(0,"end")
11580  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11581  if AWGBOffsetvalue < (-2.50-AWGB_Ext_Offset.get()):
11582  AWGBOffsetvalue = -2.50-AWGB_Ext_Offset.get()
11583  AWGBOffsetEntry.delete(0,"end")
11584  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11585  if AWGBMode.get() == 1: # Source current measure voltage mode
11586  if AWGBOffsetvalue > 200.00:
11587  AWGBOffsetvalue = 200.00
11588  AWGBOffsetEntry.delete(0,"end")
11589  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11590  if AWGBOffsetvalue < -200.00:
11591  AWGBOffsetvalue = -200.00
11592  AWGBOffsetEntry.delete(0,"end")
11593  AWGBOffsetEntry.insert(0, AWGBOffsetvalue)
11594 #
11595 def BAWGBFreq(temp):
11596  global AWGBFreqEntry, AWGBFreqvalue, AWG_2X
11597  global BodeScreenStatus, BodeDisp
11598 
11599  try:
11600  AWGBFreqvalue = float(eval(AWGBFreqEntry.get()))
11601  except:
11602  AWGBFreqEntry.delete(0,"end")
11603  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11604  if AWG_2X.get() == 2:
11605  if BodeScreenStatus.get() > 0 and BodeDisp.get() > 0:
11606  if AWGBFreqvalue > 90000: # max freq is 90KHz for Bode plotting
11607  AWGBFreqvalue = 90000
11608  AWGBFreqEntry.delete(0,"end")
11609  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11610  else:
11611  if AWGBFreqvalue > 50000: # max freq is 50KHz
11612  AWGBFreqvalue = 50000
11613  AWGBFreqEntry.delete(0,"end")
11614  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11615  else:
11616  if AWGBFreqvalue > 25000: # max freq is 25KHz
11617  AWGBFreqvalue = 25000
11618  AWGBFreqEntry.delete(0,"end")
11619  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11620  if AWGBFreqvalue < 0: # Set negative frequency entry to 0
11621  AWGBFreqvalue = 10
11622  AWGBFreqEntry.delete(0,"end")
11623  AWGBFreqEntry.insert(0, AWGBFreqvalue)
11624  # UpdateAWGB()
11625 
11627  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
11628 
11629  if AWGBPhaseDelay.get() == 1:
11630  AWGBPhaseDelay.set(0)
11631  awgbph.configure(text="Phase")
11632  phaseblab.configure(text="Deg")
11633  elif AWGBPhaseDelay.get() == 0:
11634  AWGBPhaseDelay.set(1)
11635  awgbph.configure(text="Delay")
11636  phaseblab.configure(text="mSec")
11637 
11639  global AWGBPhaseDelay, phaseblab, awgbph, awgbdel
11640 
11641  if AWGBPhaseDelay.get() == 0:
11642  phaseblab.configure(text="Deg")
11643  awgbph.configure(text="Phase")
11644  elif AWGBPhaseDelay.get() == 1:
11645  phaseblab.configure(text="mSec")
11646  awgbph.configure(text="Delay")
11647 
11648 def BAWGBPhase(temp):
11649  global AWGBPhaseEntry, AWGBPhasevalue
11650 
11651  try:
11652  AWGBPhasevalue = float(eval(AWGBPhaseEntry.get()))
11653  except:
11654  AWGBPhaseEntry.delete(0,"end")
11655  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11656 
11657  if AWGBPhasevalue > 360: # max phase is 360 degrees
11658  AWGBPhasevalue = 360
11659  AWGBPhaseEntry.delete(0,"end")
11660  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11661  if AWGBPhasevalue < 0: # min phase is 0 degrees
11662  AWGBPhasevalue = 0
11663  AWGBPhaseEntry.delete(0,"end")
11664  AWGBPhaseEntry.insert(0, AWGBPhasevalue)
11665 
11666 def BAWGBDutyCycle(temp):
11667  global AWGBDutyCycleEntry, AWGBDutyCyclevalue
11668 
11669  try:
11670  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))/100
11671  except:
11672  AWGBDutyCycleEntry.delete(0,"end")
11673  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11674 
11675  if AWGBDutyCyclevalue > 1: # max duty cycle is 100%
11676  AWGBDutyCyclevalue = 1
11677  AWGBDutyCycleEntry.delete(0,"end")
11678  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue*100)
11679  if AWGBDutyCyclevalue < 0: # min duty cycle is 0%
11680  AWGBDutyCyclevalue = 0
11681  AWGBDutyCycleEntry.delete(0,"end")
11682  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
11683  # UpdateAWGB()
11684 
11686  global AWGBShape, AWGBWave, duty2lab, AWG_2X, CHA, CHB
11687 
11688  if AWGBShape.get() == 0:
11689  AWGBWave = 'dc'
11690  duty2lab.config(text="%")
11691  BAWGBPhaseDelay()
11692  if AWGBShape.get() == 1:
11693  AWGBWave = 'sine'
11694  duty2lab.config(text="%")
11695  BAWGBPhaseDelay()
11696  if AWGBShape.get() == 2:
11697  AWGBWave = 'triangle'
11698  duty2lab.config(text="%")
11699  BAWGBPhaseDelay()
11700  if AWGBShape.get() == 3:
11701  AWGBWave = 'sawtooth'
11702  duty2lab.config(text="%")
11703  BAWGBPhaseDelay()
11704  if AWGBShape.get() == 4:
11705  AWGBWave = 'square'
11706  duty2lab.config(text="%")
11707  BAWGBPhaseDelay()
11708  if AWGBShape.get() == 5:
11709  AWGBWave = 'stairstep'
11710  duty2lab.config(text="%")
11711  BAWGBPhaseDelay()
11712  if AWGBShape.get() > 5:
11713  AWGBWave = 'arbitrary'
11714  if AWG_2X.get() == 1:
11715  CHB.mode = CHA.mode
11716  AWGBWave = 'arbitrary'
11717  # UpdateAWGB()
11718 
11720  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile
11721 
11722  # Read values from CVS file
11723  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
11724  AWGBcsvFile = filename
11725  AWGBLoadCSV()
11726 #
11728  global AWGBwaveform, AWGBLength, awgwindow, AWG_2X, AWGB2X, AWGBcsvFile
11729 
11730  try:
11731  CSVFile = open(AWGBcsvFile)
11732  # dialect = csv.Sniffer().sniff(CSVFile.read(128), delimiters=None)
11733  CSVFile.seek(0)
11734  #csv_f = csv.reader(CSVFile, dialect)
11735  csv_f = csv.reader(CSVFile, csv.excel)
11736  except:
11737  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
11738  AWGBwaveform = []
11739  ColumnNum = 0
11740  ColumnSel = 0
11741  RowNum = 0
11742  for row in csv_f:
11743  if len(row) > 1 and ColumnSel == 0:
11744  RequestColumn = askstring("Which Column?", "File contains 1 to " + str(len(row)) + " columns\n\nEnter column number to import:\n", initialvalue=1, parent=awgwindow)
11745  ColumnNum = int(RequestColumn) - 1
11746  ColumnLen = str(len(row))
11747  ColumnSel = 1
11748  try:
11749  colnum = 0
11750  for col in row:
11751  if colnum == ColumnNum:
11752  AWGBwaveform.append(float(col))
11753  colnum += 1
11754  except:
11755  print( 'skipping non-numeric row', RowNum)
11756  RowNum += 1
11757  AWGBwaveform = numpy.array(AWGBwaveform)
11759  CSVFile.close()
11760  UpdateAwgCont()
11761 
11762 # Split 2X sampled AWGBwaveform array into odd and even sample arrays
11764  global AWG_2X, AWGB2X, AWGBwaveform
11765  global AWGFiltB, AWGFiltBCoef
11766 
11767  # check if AWG digital filter box checked
11768  if AWGFiltB.get() == 1:
11769  BufLen = len(AWGBwaveform)
11770  CoefLen = len(AWGFiltBCoef)/2
11771  AWGBwaveform = numpy.pad(AWGBwaveform, (CoefLen,CoefLen), 'wrap')
11772  AWGBwaveform = numpy.convolve(AWGBwaveform, AWGFiltBCoef)
11773  AWGBwaveform = numpy.roll(AWGBwaveform, -CoefLen)
11774  AWGBwaveform = AWGBwaveform[CoefLen:BufLen+CoefLen]
11775 
11776  if AWG_2X.get() == 2:
11777  Tempwaveform = []
11778  AWGB2X = []
11779  AWGB2X = AWGBwaveform[::2] # even numbered samples
11780  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
11781  AWGBwaveform = Tempwaveform
11782 #
11784  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
11785  global AWG_2X, AWGA2X
11786 
11787 # Read values from WAV file
11788  filename = askopenfilename(defaultextension = ".wav", filetypes=[("WAV files", "*.wav")], parent=awgwindow)
11789  AWGBwavFile = filename
11790  AWGBLoadWAV()
11791 #
11793  global AWGBwaveform, AWGBLength, awgwindow, AWGBwavFile
11794  global AWG_2X, AWGA2X
11795 
11796  try:
11797  spf = wave.open(AWGBwavFile,'r')
11798  except:
11799  showwarning("WARNING","No such file found or wrong format!", parent=awgwindow)
11800  AWGBwaveform = []
11801  #If Stereo
11802  if spf.getnchannels() == 2:
11803  showwarning("WARNING","Only mono files supported!", parent=awgwindow)
11804  return()
11805  #Extract Raw Audio from Wav File
11806  Length = spf.getnframes()
11807  if Length > 90000: # limit to first 90K samples
11808  Length = 90000
11809  signal = spf.readframes(Length)
11810  WAVsignal = numpy.fromstring(signal, 'Int16') # convert strings to Int
11811  # offset and scale for 0 5 V range
11812  AWGBwaveform = (WAVsignal * 2.5 / 32768) + 2.5
11813  AWGBwaveform = numpy.array(AWGBwaveform)
11815  spf.close()
11816  UpdateAwgCont()
11817 
11819  global AWGBwaveform, AWGBLength, awgwindow
11820 
11821  filename = asksaveasfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=awgwindow)
11822  numpy.savetxt(filename, AWGBwaveform, delimiter=",", fmt='%2.4f')
11823 
11825  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11826  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
11827  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
11828  global DFiltACoef, DFiltBCoef, AWGBShapeLabel, AWGBLength
11829  global AWG_2X, AWGA2X
11830 
11831  TempString = AWGBMathString
11832  AWGBShapeLabel.config(text = "Math" ) # change displayed value
11833  AWGBMathString = askstring("AWG B Math Formula", "Current Formula: " + AWGBMathString + "\n\nNew Formula:\n", initialvalue=AWGBMathString, parent=awgwindow)
11834  if (AWGBMathString == None): # If Cancel pressed, then None
11835  AWGBMathString = TempString
11836  return
11837  try:
11838  AWGBwaveform = eval(AWGBMathString)
11839  except:
11840  showwarning("Syntax Error","Syntax Error in entered string!", parent=awgwindow)
11841  AWGBwaveform = numpy.array(AWGBwaveform)
11843  AWGBLength.config(text = "L = " + str(int(len(AWGBwaveform)))) # change displayed value
11844  UpdateAwgCont()
11845 #
11847  global AWGAwaveform, AWGSAMPLErate, VBuffA, VBuffB, IBuffA, IBuffB
11848  global AWGBwaveform, VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGBMathString
11849  global FFTBuffA, FFTBuffB, FFTwindowshape, AWGBLength, awgwindow
11850  global DFiltACoef, DFiltBCoef, AWGBShapeLabel
11851  global AWG_2X, AWGA2X
11852 
11853  AWGBwaveform = eval(AWGBMathString)
11854  AWGBwaveform = numpy.array(AWGBwaveform)
11856  UpdateAwgCont()
11857 #
11859  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBFreqvalue, awgwindow
11860  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11861  global AWGA2X, AWG_2X, SAMPLErate, BaseSampleRate, duty2lab
11862  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11863 
11864  Max_term = int(AWGBDutyCyclevalue*100)
11865 
11866  BAWGBAmpl(0)
11867  BAWGBOffset(0)
11868  BAWGBFreq(0)
11869  if AWG_2X.get() == 1:
11870  TempRate = (BaseSampleRate*2)
11871  else:
11872  TempRate = BaseSampleRate
11873  AWGBwaveform = []
11874  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*numpy.pi, int(TempRate/AWGBFreqvalue))) # the fundamental
11875  k = 3
11876  while k <= Max_term:
11877  # Add odd harmonics up to max_term
11878  Harmonic = (math.sin(k*numpy.pi/2)/k)*(numpy.cos(numpy.linspace(0, k*2*numpy.pi, int(TempRate/AWGBFreqvalue))))
11879  AWGBwaveform = AWGBwaveform + Harmonic
11880  k = k + 2 # skip even numbers
11881  if AWG_Amp_Mode.get() == 0:
11882  amplitude = (AWGBOffsetvalue-AWGBAmplvalue)/2
11883  offset = (AWGBOffsetvalue+AWGBAmplvalue)/2
11884  else:
11885  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
11886  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
11887  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
11889  duty2lab.config(text="Harmonics")
11890  BAWGBPhaseDelay()
11891  UpdateAwgCont()
11892 #
11894  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
11895  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay, AWGBMode
11896  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode
11897  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset, AWGRecLength
11898 
11899  BAWGBAmpl(0)
11900  BAWGBOffset(0)
11901  BAWGBFreq(0)
11902  BAWGBPhase(0)
11903  BAWGBDutyCycle(0)
11904 
11905  if AWGBFreqvalue < 10.0: # if frequency is less than 10 Hz use libsmu sine function
11906  AWGBShape.set(1)
11907  BAWGBShape()
11908  UpdateAwgCont()
11909  return
11910 
11911  if AWGBFreqvalue > 0.0:
11912  if AWG_2X.get() == 2:
11913  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11914  else:
11915  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11916  else:
11917  AWGBperiodvalue = 10.0
11918 
11919  if AWGBPhaseDelay.get() == 0:
11920  if AWGBPhasevalue > 0:
11921  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
11922  else:
11923  AWGBdelayvalue = 0.0
11924  elif AWGBPhaseDelay.get() == 1:
11925  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
11926  Cycles = int(AWGRecLength/AWGBperiodvalue)
11927  if Cycles < 1:
11928  Cycles = 1
11929  RecLength = int(Cycles * AWGBperiodvalue)
11930  if RecLength % 2 != 0: # make sure record length is even so 2X mode works for all Freq
11931  RecLength = RecLength + 1
11932  AWGBwaveform = []
11933  AWGBwaveform = numpy.cos(numpy.linspace(0, 2*Cycles*numpy.pi, RecLength))
11934 
11935  if AWG_Amp_Mode.get() == 0:
11936  if AWGBMode.get() == 1: # convert to mA
11937  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2000.0
11938  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2000.0
11939  else:
11940  amplitude = (AWGBOffsetvalue-AWGBAmplvalue) / -2.0
11941  offset = (AWGBOffsetvalue+AWGBAmplvalue) / 2.0
11942  else:
11943  if AWGBMode.get() == 1: # convert to mA
11944  amplitude = AWGBAmplvalue/1000.0
11945  offset = AWGBOffsetvalue/1000.0
11946  else:
11947  amplitude = AWGBAmplvalue*AWGB_Ext_Gain.get()
11948  offset = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get()
11949  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
11950  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
11951  #
11952  if AWG_2X.get() == 2:
11953  Tempwaveform = []
11954  AWGB2X = []
11955  AWGB2X = AWGBwaveform[::2] # even numbered samples
11956  Tempwaveform = AWGBwaveform[1::2] # odd numbered samples Tempwaveform
11957  AWGBwaveform = Tempwaveform
11958  BAWGBPhaseDelay()
11959  duty2lab.config(text="%")
11960  UpdateAwgCont()
11961 #
11963  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength
11964  global AWGBDutyCyclevalue, AWGBFreqvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
11965  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
11966  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
11967 
11968  BAWGBAmpl(0)
11969  BAWGBOffset(0)
11970  BAWGBFreq(0)
11971  BAWGBPhase(0)
11972  BAWGBDutyCycle(0)
11973 
11974  if AWGBFreqvalue > 0.0:
11975  if AWG_2X.get() == 2:
11976  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
11977  else:
11978  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
11979  else:
11980  AWGBperiodvalue = 0.0
11981  if AWG_Amp_Mode.get() == 1:
11982  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
11983  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
11984  else:
11985  MaxV = AWGBOffsetvalue
11986  MinV = AWGBAmplvalue
11987 
11988  PulseWidth = int(AWGBDutyCyclevalue*100)
11989  PulseSamples = int(AWGBperiodvalue/PulseWidth)
11990  AWGBwaveform = []
11991  for i in range(PulseSamples): #(i = 0; i < cPulse; i++)
11992  v = round(PulseWidth/2*(1+numpy.sin(i*2*numpy.pi/PulseSamples)))
11993  # print(v)
11994  for j in range(PulseWidth): #(j = 0; j < cLength; j++)
11995  if j >= v:
11996  AWGBwaveform.append(MaxV) # j>=v?1:0
11997  else:
11998  AWGBwaveform.append(MinV) # j>=v?1:0
12000  duty2lab.config(text="PWidth")
12001  UpdateAwgCont()
12002 #
12004  global AWGBwaveform, AWGSampleRate, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBperiodvalue
12005  global AWGBDutyCyclevalue, AWGBFreqvalue, duty2lab, AWGBgain, AWGBoffset, AWGBPhaseDelay
12006  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12007  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12008 
12009  BAWGBAmpl(0)
12010  BAWGBOffset(0)
12011  BAWGBFreq(0)
12012  BAWGBPhase(0)
12013  BAWGBDutyCycle(0)
12014 
12015  if AWGBFreqvalue > 0.0:
12016  if AWG_2X.get() == 1:
12017  AWGBperiodvalue = int((BaseSampleRate*2)/AWGBFreqvalue)
12018  if AWGBperiodvalue % 2 != 0: # make sure record length is even so 2X mode works for all Freq
12019  AWGBperiodvalue = AWGBperiodvalue + 1
12020  else:
12021  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12022  else:
12023  AWGBperiodvalue = 0.0
12024  if AWG_Amp_Mode.get() == 1:
12025  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12026  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12027  else:
12028  MaxV = AWGBOffsetvalue
12029  MinV = AWGBAmplvalue
12030 
12031  if AWGBPhaseDelay.get() == 0:
12032  if AWGBPhasevalue > 0:
12033  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12034  else:
12035  AWGBdelayvalue = 0.0
12036  elif AWGBPhaseDelay.get() == 1:
12037  AWGBdelayvalue = AWGBPhasevalue * SAMPLErate / 1000
12038 
12039  Cycles = int(AWGBDutyCyclevalue*100)
12040  NCycles = -1 * Cycles
12041  AWGBwaveform = []
12042  AWGBwaveform = numpy.sinc(numpy.linspace(NCycles, Cycles, int(SAMPLErate/AWGBFreqvalue)))
12043  amplitude = (MaxV-MinV) / 2.0
12044  offset = (MaxV+MinV) / 2.0
12045  AWGBwaveform = (AWGBwaveform * amplitude) + offset # scale and offset the waveform
12046  Cycles = int(37500/AWGBperiodvalue)
12047  if Cycles < 1:
12048  Cycles = 1
12049  if Cycles > 1:
12050  Extend = int((Cycles-1.0)*AWGBperiodvalue/2.0)
12051  AWGBwaveform = numpy.pad(AWGBwaveform, (Extend,Extend), 'wrap')
12052  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12054  duty2lab.config(text="Cycles")
12055  BAWGBPhaseDelay()
12056  UpdateAwgCont()
12057 #
12059  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12060  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12061  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12062  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12063  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12064  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12065 
12066  BAWGBAmpl(0)
12067  BAWGBOffset(0)
12068  BAWGBFreq(0)
12069  BAWGBPhase(0)
12070  BAWGBDutyCycle(0)
12071 
12072  if AWGBFreqvalue > 0.0:
12073  if AWG_2X.get() == 2:
12074  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12075  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12076  else:
12077  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12078  SamplesPermS = int(BaseSampleRate/1000) # 100
12079  else:
12080  AWGBperiodvalue = 0.0
12081  if AWG_Amp_Mode.get() == 1:
12082  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12083  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12084  else:
12085  MaxV = AWGBOffsetvalue
12086  MinV = AWGBAmplvalue
12087  AWGBwaveform = []
12088  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12089  if SlopeValue <= 0:
12090  SlopeValue = 1
12091  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12092  if PulseWidth <=0:
12093  PulseWidth = 1
12094  Remainder = int((AWGBperiodvalue - PulseWidth - SlopeValue)/2)
12095  if Remainder <= 0:
12096  Remainder = 1
12097  PulseWidth = PulseWidth - SlopeValue
12098  if PulseWidth <=0:
12099  PulseWidth = 1
12100  StepAmp = (MaxV - MinV)/2
12101  StepOff = (MaxV + MinV)/2
12102  AWGBwaveform = StepAmp * (numpy.cos(numpy.linspace(0, 2*numpy.pi, SlopeValue*2))) + StepOff
12103  MidArray = numpy.ones(PulseWidth) * MinV
12104  AWGBwaveform = numpy.insert(AWGBwaveform, SlopeValue, MidArray)
12105  AWGBwaveform = numpy.pad(AWGBwaveform, (Remainder, Remainder), 'edge')
12106  if AWGBBurstFlag.get() == 1:
12107  TempOneCycle = AWGBwaveform
12108  for i in range(AWGBCycles-1):
12109  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12110  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12111  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12113  duty2lab.config(text="%")
12114  phaseblab.config(text = "Rise Time")
12115  UpdateAwgCont()
12116 #
12118  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12119  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12120  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12121  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12122  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12123  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12124 
12125  BAWGBAmpl(0)
12126  BAWGBOffset(0)
12127  BAWGBFreq(0)
12128  BAWGBPhase(0)
12129  BAWGBDutyCycle(0)
12130 
12131  if AWGBFreqvalue > 0.0:
12132  if AWG_2X.get() == 2:
12133  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12134  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12135  else:
12136  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12137  SamplesPermS = int(BaseSampleRate/1000) # 100
12138  else:
12139  AWGBperiodvalue = 0.0
12140  if AWG_Amp_Mode.get() == 1:
12141  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12142  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12143  else:
12144  MaxV = AWGBOffsetvalue
12145  MinV = AWGBAmplvalue
12146  AWGBwaveform = []
12147  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12148  if SlopeValue <= 0:
12149  SlopeValue = 1
12150  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12151  if PulseWidth <=0:
12152  PulseWidth = 1
12153  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12154  if Remainder <= 0:
12155  Remainder = 1
12156  PulseWidth = PulseWidth - SlopeValue
12157  if PulseWidth <=0:
12158  PulseWidth = 1
12159  StepValue = (MaxV - MinV) / SlopeValue
12160  SampleValue = MinV
12161  for i in range(SlopeValue):
12162  AWGBwaveform.append(SampleValue)
12163  SampleValue = SampleValue + StepValue
12164  for i in range(PulseWidth):
12165  AWGBwaveform.append(MaxV)
12166  for i in range(SlopeValue):
12167  AWGBwaveform.append(SampleValue)
12168  SampleValue = SampleValue - StepValue
12169  for i in range(Remainder):
12170  AWGBwaveform.append(MinV)
12171  if AWGBBurstFlag.get() == 1:
12172  TempOneCycle = AWGBwaveform
12173  for i in range(AWGBCycles-1):
12174  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12175  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12176  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12178  duty2lab.config(text="%")
12179  phaseblab.config(text = "Rise Time")
12180  UpdateAwgCont()
12181 #
12183  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12184  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12185  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12186  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12187  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12188  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12189 
12190  BAWGBAmpl(0)
12191  BAWGBOffset(0)
12192  BAWGBFreq(0)
12193  BAWGBPhase(0)
12194 
12195  try:
12196  AWGBDutyCyclevalue = float(eval(AWGBDutyCycleEntry.get()))
12197  except:
12198  AWGBDutyCycleEntry.delete(0,"end")
12199  AWGBDutyCycleEntry.insert(0, AWGBDutyCyclevalue)
12200 
12201  if AWGBFreqvalue > 0.0:
12202  if AWG_2X.get() == 2:
12203  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12204  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12205  else:
12206  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12207  SamplesPermS = int(BaseSampleRate/1000) # 100
12208  else:
12209  AWGBperiodvalue = 0.0
12210  if AWG_Amp_Mode.get() == 1:
12211  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12212  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12213  else:
12214  MaxV = AWGBOffsetvalue
12215  MinV = AWGBAmplvalue
12216  AWGBwaveform = []
12217  SlopeValue = int(AWGBPhasevalue*SamplesPermS) # convert mS to samples
12218  if SlopeValue <= 0:
12219  SlopeValue = 1
12220  PulseWidth = int(AWGBDutyCyclevalue*SamplesPermS) # convert mS to samples
12221  if PulseWidth <=0:
12222  PulseWidth = 1
12223  Remainder = int(AWGBperiodvalue - PulseWidth) - SlopeValue
12224  if Remainder <= 0:
12225  Remainder = 1
12226  PulseWidth = PulseWidth - SlopeValue
12227  if PulseWidth <=0:
12228  PulseWidth = 1
12229  StepValue = (MaxV - MinV) / SlopeValue
12230  SampleValue = MinV
12231  for i in range(SlopeValue):
12232  AWGBwaveform.append(SampleValue)
12233  SampleValue = SampleValue + StepValue
12234  for i in range(PulseWidth):
12235  AWGBwaveform.append(MaxV)
12236  for i in range(SlopeValue):
12237  AWGBwaveform.append(SampleValue)
12238  SampleValue = SampleValue - StepValue
12239  for i in range(Remainder):
12240  AWGBwaveform.append(MinV)
12241  if AWGBBurstFlag.get() == 1:
12242  TempOneCycle = AWGBwaveform
12243  for i in range(AWGBCycles-1):
12244  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12245  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12246  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12248  duty2lab.config(text="Width mS")
12249  phaseblab.config(text = "Rise Time")
12250  UpdateAwgCont()
12251 #
12253  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12254  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12255  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12256  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12257  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12258  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12259 
12260  BAWGBAmpl(0)
12261  BAWGBOffset(0)
12262  BAWGBFreq(0)
12263  BAWGBPhase(0)
12264  BAWGBDutyCycle(0)
12265 
12266  if AWGBFreqvalue > 0.0:
12267  if AWG_2X.get() == 2:
12268  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12269  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12270  else:
12271  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12272  SamplesPermS = int(BaseSampleRate/1000) # 100
12273  else:
12274  AWGBperiodvalue = 0.0
12275  if AWG_Amp_Mode.get() == 1:
12276  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12277  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12278  else:
12279  MaxV = AWGBOffsetvalue
12280  MinV = AWGBAmplvalue
12281  AWGBwaveform = []
12282  SlopeValue = int(AWGBPhasevalue*SamplesPermS)
12283  if SlopeValue <= 0:
12284  SlopeValue = 1
12285  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12286  if PulseWidth <=0:
12287  PulseWidth = 1
12288  Remainder = int(AWGBperiodvalue - PulseWidth)
12289  if Remainder <= 0:
12290  Remainder = 1
12291  PulseWidth = PulseWidth - SlopeValue
12292  if PulseWidth <=0:
12293  PulseWidth = 1
12294  StepValue = (MaxV - MinV) / SlopeValue
12295  SampleValue = MinV
12296  for i in range(SlopeValue):
12297  AWGBwaveform.append(SampleValue)
12298  SampleValue = SampleValue + StepValue
12299  for i in range(PulseWidth):
12300  AWGBwaveform.append(MaxV)
12301  for i in range(Remainder):
12302  AWGBwaveform.append(MinV)
12303  if AWGBBurstFlag.get() == 1:
12304  TempOneCycle = AWGBwaveform
12305  for i in range(AWGBCycles-1):
12306  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12307  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12308  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12310  duty2lab.config(text="%")
12311  phaseblab.config(text = "Slope Time")
12312  UpdateAwgCont()
12313 #
12315  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12316  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12317  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12318  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12319  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12320  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12321 
12322  BAWGBAmpl(0)
12323  BAWGBOffset(0)
12324  BAWGBFreq(0)
12325  BAWGBPhase(0)
12326  BAWGBDutyCycle(0)
12327 
12328  if AWGBFreqvalue > 0.0:
12329  if AWG_2X.get() == 2:
12330  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12331  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12332  else:
12333  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12334  SamplesPermS = int(BaseSampleRate/1000) # 100
12335  else:
12336  AWGBperiodvalue = 0.0
12337  if AWG_Amp_Mode.get() == 1:
12338  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12339  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12340  else:
12341  MaxV = AWGBOffsetvalue
12342  MinV = AWGBAmplvalue
12343  #
12344  if AWGBPhaseDelay.get() == 0:
12345  if AWGBPhasevalue > 0:
12346  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12347  else:
12348  AWGBdelayvalue = 0.0
12349  elif AWGBPhaseDelay.get() == 1:
12350  AWGBdelayvalue = AWGBPhasevalue * AWGSAMPLErate / 1000
12351  #
12352  AWGBwaveform = []
12353  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue)
12354  if PulseWidth <=0:
12355  PulseWidth = 1
12356  Remainder = int(AWGBperiodvalue - PulseWidth)
12357  if Remainder <= 0:
12358  Remainder = 1
12359  UpStepValue = (MaxV - MinV) / PulseWidth
12360  DownStepValue = (MaxV - MinV) / Remainder
12361  SampleValue = MinV
12362  for i in range(PulseWidth):
12363  AWGBwaveform.append(SampleValue)
12364  SampleValue = SampleValue + UpStepValue
12365  for i in range(Remainder):
12366  AWGBwaveform.append(SampleValue)
12367  SampleValue = SampleValue - DownStepValue
12368  AWGBwaveform = numpy.roll(AWGBwaveform, int(AWGBdelayvalue))
12369  if AWGBBurstFlag.get() == 1:
12370  TempOneCycle = AWGBwaveform
12371  for i in range(AWGBCycles-1):
12372  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12373  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12374  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12376  BAWGBPhaseDelay()
12377  duty2lab.config(text = "Symmetry")
12378  BAWGBPhaseDelay()
12379  UpdateAwgCont()
12380 #
12382  global AWGBwaveform, AWGBAmplvalue, AWGBOffsetvalue, AWGBLength, AWGBPhaseDelay
12383  global AWGBFreqvalue, AWGBperiodvalue, AWGSAMPLErate, AWGBDutyCyclevalue, AWGBPhasevalue
12384  global AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12385  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12386  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12387  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12388 
12389  BAWGBAmpl(0)
12390  BAWGBOffset(0)
12391  BAWGBFreq(0)
12392  BAWGBPhase(0)
12393  BAWGBDutyCycle(0)
12394 
12395  if AWGBFreqvalue > 0.0:
12396  if AWG_2X.get() == 2:
12397  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12398  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12399  else:
12400  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12401  SamplesPermS = int(BaseSampleRate/1000) # 100
12402  else:
12403  AWGBperiodvalue = 0.0
12404  if AWG_Amp_Mode.get() == 1:
12405  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12406  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12407  else:
12408  MaxV = AWGBOffsetvalue
12409  MinV = AWGBAmplvalue
12410  AWGBwaveform = []
12411  PulseWidth = int(AWGBperiodvalue * AWGBDutyCyclevalue / 2)
12412  if AWGBPhaseDelay.get() == 0:
12413  DelayValue = int(AWGBperiodvalue*(AWGBPhasevalue/360))
12414  elif AWGBPhaseDelay.get() == 1:
12415  DelayValue = int(AWGBPhasevalue*SamplesPermS)
12416  for i in range(DelayValue-PulseWidth):
12417  AWGBwaveform.append((MinV+MaxV)/2)
12418  for i in range(PulseWidth):
12419  AWGBwaveform.append(MaxV)
12420  for i in range(PulseWidth):
12421  AWGBwaveform.append(MinV)
12422  DelayValue = int(AWGBperiodvalue-DelayValue)
12423  for i in range(DelayValue-PulseWidth):
12424  AWGBwaveform.append((MinV+MaxV)/2)
12425  if AWGBBurstFlag.get() == 1:
12426  TempOneCycle = AWGBwaveform
12427  for i in range(AWGBCycles-1):
12428  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12429  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12430  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'edge')
12432  duty2lab.config(text = "Duty Cycle")
12433  BAWGBPhaseDelay()
12434  UpdateAwgCont()
12435 
12437  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
12438  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12439  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12440  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12441  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12442 
12443  BAWGBAmpl(0)
12444  BAWGBOffset(0)
12445  BAWGBFreq(0)
12446 
12447  if AWGBFreqvalue > 0.0:
12448  if AWG_2X.get() == 2:
12449  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12450  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12451  else:
12452  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12453  SamplesPermS = int(BaseSampleRate/1000) # 100
12454  else:
12455  AWGBperiodvalue = 0.0
12456 
12457  if AWGBAmplvalue > AWGBOffsetvalue:
12458  MinV = AWGBOffsetvalue
12459  MaxV = AWGBAmplvalue
12460  else:
12461  MaxV = AWGBOffsetvalue
12462  MinV = AWGBAmplvalue
12463  if AWG_Amp_Mode.get() == 1:
12464  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12465  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12466  AWGBwaveform = []
12467  AWGBwaveform = numpy.random.uniform(MinV, MaxV, int(AWGBperiodvalue))
12468  Mid = (MaxV+MinV)/2
12469  if AWGBBurstFlag.get() == 1:
12470  TempOneCycle = AWGBwaveform
12471  for i in range(AWGBCycles-1):
12472  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12473  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12474  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
12476  BAWGBPhaseDelay()
12477  UpdateAwgCont()
12478 
12480  global AWGBwaveform, AWGSAMPLErate, AWGBAmplvalue, AWGBOffsetvalue, AWGBFreqvalue
12481  global AWGBLength, AWGBperiodvalue, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12482  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay
12483  global AWGB2X, AWG_2X, SAMPLErate, BaseSampleRate
12484  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12485 
12486  BAWGBAmpl(0)
12487  BAWGBOffset(0)
12488  BAWGBFreq(0)
12489 
12490  if AWGBFreqvalue > 0.0:
12491  if AWG_2X.get() == 2:
12492  AWGBperiodvalue = (BaseSampleRate*2)/AWGBFreqvalue
12493  SamplesPermS = int((BaseSampleRate*2)/1000) # 200
12494  else:
12495  AWGBperiodvalue = BaseSampleRate/AWGBFreqvalue
12496  SamplesPermS = int(BaseSampleRate/1000) # 100
12497  else:
12498  AWGBperiodvalue = 0.0
12499  if AWGBAmplvalue > AWGBOffsetvalue:
12500  MinV = AWGBOffsetvalue
12501  MaxV = AWGBAmplvalue
12502  else:
12503  MaxV = AWGBOffsetvalue
12504  MinV = AWGBAmplvalue
12505  if AWG_Amp_Mode.get() == 1:
12506  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12507  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12508  AWGBwaveform = []
12509  AWGBwaveform = numpy.random.normal((MinV+MaxV)/2, (MaxV-MinV)/3, int(AWGBperiodvalue))
12510  Mid = (MaxV+MinV)/2
12511  if AWGBBurstFlag.get() == 1:
12512  TempOneCycle = AWGBwaveform
12513  for i in range(AWGBCycles-1):
12514  AWGBwaveform = numpy.concatenate((AWGBwaveform, TempOneCycle))
12515  TempDelay = int(AWGBBurstDelay*SamplesPermS) # convert mS to samples
12516  AWGBwaveform = numpy.pad(AWGBwaveform, (TempDelay, 0), 'constant', constant_values=(Mid))
12518  BAWGBPhaseDelay()
12519  UpdateAwgCont()
12520 
12522  global AWGBMode, AWGBIOMode, AWGBModeLabel, DevID, devx, DevOne, CHB, HWRevOne
12523  global EnableScopeOnly
12524 
12525  if AWGBMode.get() == 0: # Source Voltage measure current mode
12526  label_txt = "SVMI"
12527  elif AWGBMode.get() == 1: # Source current measure voltage mode
12528  label_txt = "SIMV"
12529  elif AWGBMode.get() == 2: # High impedance mode
12530  label_txt = "Hi-Z"
12531  if AWGBIOMode.get() > 0: # Split Input / Output mode
12532  if HWRevOne == "D":
12533  if AWGBMode.get() == 0:
12534  AWGBMode.set(1)
12535  CHB.set_mode('i') # channel must be in source current mode for rev D boards
12536  label_txt = "SIMV"
12537  label_txt = label_txt + " Split I/O"
12538  if EnableScopeOnly == 0:
12539  label_txt = label_txt + " Mode"
12540  AWGBModeLabel.config(text = label_txt ) # change displayed value
12541  ReMakeAWGwaves()
12542  #UpdateAwgCont()
12543 
12545  global AWGBAmplvalue, AWGBOffsetvalue, AWGA2X, AWG_2X
12546  global AWGBFreqvalue, AWGBPhasevalue, AWGBPhaseDelay
12547  global AWGBDutyCyclevalue, FSweepMode, AWGBRepeatFlag, AWGSync
12548  global AWGBWave, AWGBMode, AWGBTerm, AWGBwaveform, AWGBIOMode
12549  global CHA, CHB, AWGSAMPLErate, DevID, devx, HWRevOne
12550  global amp2lab, off2lab, AWG_Amp_Mode # 0 = Min/Max mode, 1 = Amp/Offset
12551  global AWGA2X, AWGB2X, AWGAWave, AWGARepeatFlag, EnableScopeOnly
12552  global AWGA_Ext_Gain, AWGA_Ext_Offset, AWGB_Ext_Gain, AWGB_Ext_Offset
12553 
12554  if AWG_Amp_Mode.get() == 0: # 0 = Min/Max mode, 1 = Amp/Offset
12555  amp2lab.config(text = "Min Ch B" ) # change displayed value
12556  off2lab.config(text = "Max Ch B" ) # change displayed value
12557  else:
12558  amp2lab.config(text = "Amp Ch B" )
12559  off2lab.config(text = "Off Ch B" )
12560 #
12561  if AWG_2X.get() == 1:
12562  AWGBWave = 'arbitrary'
12563  if AWGBFreqvalue > 0.0:
12564  AWGBperiodvalue = AWGSAMPLErate/AWGBFreqvalue
12565  else:
12566  AWGBperiodvalue = 0.0
12567 #
12568  if AWGBPhaseDelay.get() == 0:
12569  if AWGBWave == 'square':
12570  AWGBPhasevalue = AWGBPhasevalue + 270.0
12571  if AWGBPhasevalue > 359:
12572  AWGBPhasevalue = AWGBPhasevalue - 360
12573  if AWGBPhasevalue > 0:
12574  AWGBdelayvalue = AWGBperiodvalue * AWGBPhasevalue / 360.0
12575  else:
12576  AWGBdelayvalue = 0.0
12577  elif AWGBPhaseDelay.get() == 1:
12578  AWGBdelayvalue = AWGBPhasevalue * 100
12579 #
12580  if AWGBTerm.get() == 0: # Open termination
12581  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
12582  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
12583  elif AWGBTerm.get() == 1: # 50 Ohm termination to GND
12584  devx.ctrl_transfer( 0x40, 0x51, 37, 0, 0, 0, 100) # set 2.5 V switch to open
12585  devx.ctrl_transfer( 0x40, 0x50, 38, 0, 0, 0, 100) # set GND switch to closed
12586  elif AWGBTerm.get() == 2: # 50 Ohm termination to +2.5 Volts
12587  devx.ctrl_transfer( 0x40, 0x50, 37, 0, 0, 0, 100) # set 2.5 V switch to closed
12588  devx.ctrl_transfer( 0x40, 0x51, 38, 0, 0, 0, 100) # set GND switch to open
12589 
12590  if AWGBWave == 'dc':
12591  if AWG_2X.get() == 1:
12592  AWGBWave == 'arbitrary'
12593  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
12594  else:
12595  if AWGBMode.get() == 0: # Source Voltage measure current mode
12596  if AWGBIOMode.get() == 0:
12597  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
12598  else:
12599  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
12600  CHB.constant(AWGBOffsetvalue)
12601  if AWGBMode.get() == 1: # Source current measure Voltage mode
12602  if AWGBIOMode.get() == 0:
12603  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
12604  else:
12605  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
12606  CHB.constant(AWGBOffsetvalue/1000)
12607  if AWGBMode.get() == 2: # Hi impedance mode
12608  if AWGBIOMode.get() == 0:
12609  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
12610  else:
12611  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
12612 #
12613  if AWGBIOMode.get() > 0: # Split Input / Output mode
12614  if HWRevOne == "D":
12615  AWGBMode.set(1)
12616  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12617 #
12618  else:
12619  if AWGBMode.get() == 0: # Source Voltage measure current mode
12620  if AWGBIOMode.get() == 0:
12621  CHB.mode = Mode.SVMI # Put CHB in SVMI mode
12622  else:
12623  CHB.mode = Mode.SVMI_SPLIT # Put CHB in SVMI split mode
12624  if AWGBMode.get() == 1: # Source current measure Voltage mode
12625  if AWGBIOMode.get() == 0:
12626  CHB.mode = Mode.SIMV # Put CHB in SIMV mode
12627  else:
12628  CHB.mode = Mode.SIMV_SPLIT # Put CHB in SIMV split mode
12629  AWGBOffsetvalue = AWGBOffsetvalue/1000
12630  AWGBAmplvalue = AWGBAmplvalue/1000
12631  if AWGBMode.get() == 2: # Hi impedance mode
12632  if AWGBIOMode.get() == 0:
12633  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
12634  else:
12635  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
12636  else:
12637  if AWG_Amp_Mode.get() == 1:
12638  MaxV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() + (AWGBAmplvalue * AWGB_Ext_Gain.get())
12639  MinV = (AWGBOffsetvalue * AWGB_Ext_Gain.get()) + AWGB_Ext_Offset.get() - (AWGBAmplvalue * AWGB_Ext_Gain.get())
12640  else:
12641  MaxV = AWGBOffsetvalue
12642  MinV = AWGBAmplvalue
12643  try: # keep going even if low level library returns an error
12644  if AWGBWave == 'sine':
12645  CHB.sine(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12646  elif AWGBWave == 'triangle':
12647  CHB.triangle(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12648  elif AWGBWave == 'sawtooth':
12649  CHB.sawtooth(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12650  elif AWGBWave == 'square':
12651  CHB.square(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue, AWGBDutyCyclevalue)
12652  elif AWGBWave == 'stairstep':
12653  CHB.stairstep(MaxV, MinV, AWGBperiodvalue, AWGBdelayvalue)
12654  elif AWGBWave == 'arbitrary':
12655  if EnableScopeOnly == 0:
12656  AddAWGBNoise()
12657  if AWGSync.get() == 0:
12658  AWGBRepeatFlag.set(1)
12659  if AWG_2X.get() == 1:
12660  AWGBWave == 'arbitrary'
12661  CHB.arbitrary(AWGA2X, AWGARepeatFlag.get())
12662  else:
12663  CHB.arbitrary(AWGBwaveform, AWGBRepeatFlag.get()) # set repeat flag
12664  except:
12665  donothing()
12666  if AWGBIOMode.get() > 0: # Split Input / Output mode
12667  if HWRevOne == "D":
12668  AWGBMode.set(1)
12669  CHB.mode = Mode.SIMV_SPLIT # channel must be in source current mode
12670 #
12672  global AWG_2X, AWGA2X, AWGBwaveform
12673  global AWGBNoiseEntry, AWGBsbnoise, AWGBNoisevalue
12674 
12675  if AWGBsbnoise.get() == "None":
12676  return
12677  else:
12678  try:
12679  AWGBNoisevalue = float(eval(AWGBNoiseEntry.get()))
12680  except:
12681  AWGBNoiseEntry.delete(0,"end")
12682  AWGBNoiseEntry.insert(0, AWGBNoisevalue)
12683  if AWGBNoisevalue == 0.0:
12684  return
12685  AWGBNoiseform = []
12686  if AWGBsbnoise.get() == "Gaussian":
12687  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGBwaveform))
12688  else:
12689  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGBwaveform))
12690  AWGBwaveform = AWGBwaveform + AWGBNoiseform
12691  if AWG_2X.get() == 2:
12692  if AWGBsbnoise.get() == "Gaussian":
12693  AWGBNoiseform = numpy.random.normal(0.0, abs((AWGBNoisevalue)/3), len(AWGA2X))
12694  else:
12695  AWGBNoiseform = numpy.random.uniform((-AWGBNoisevalue)/2, (AWGBNoisevalue)/2, len(AWGA2X))
12696  AWGA2X = AWGA2X + AWGBNoiseform
12697 #
12699  global session, CHA, CHB, AWGSync
12700  # if running and in continuous streaming mode temp stop, flush buffer and restart to change AWG settings
12701  if (RUNstatus.get() == 1) and AWGSync.get() == 0:
12702  if session.continuous:
12703  session.end()
12704  BAWGEnab() # set-up new AWG settings
12705  time.sleep(0.01) # wait awhile here for some reason
12706  session.start(0)
12707 #
12709  ReMakeAWGwaves()
12710 
12711 def BAWGEnab():
12712  global AWGAMode, AWGBMode, AWGSync
12713  global CHA, CHB, discontloop, contloop, session
12714 
12715  # Stream = False
12716  # print "Updateing AWGs"
12717  BAWGAAmpl(0)
12718  BAWGAOffset(0)
12719  BAWGAFreq(0)
12720  BAWGAPhase(0)
12721  BAWGADutyCycle(0)
12722  BAWGAShape()
12723  BAWGBAmpl(0)
12724  BAWGBOffset(0)
12725  BAWGBFreq(0)
12726  BAWGBPhase(0)
12727  BAWGBDutyCycle(0)
12728  BAWGBShape()
12729  UpdateAWGA()
12730  UpdateAWGB()
12731 
12732 def BAWGSync():
12733  global RUNstatus, AWGSync, session, CHA, CHB, IAScreenStatus, IADisp
12734 
12735  if (RUNstatus.get() == 1): # do this only if running
12736  if IAScreenStatus.get() > 0 and IADisp.get() > 0:
12737  AWGSync.set(1)
12738  return
12739  if AWGSync.get() == 0:
12740  #UpdateAwgCont()
12741  session.flush()
12742  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
12743  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
12744  BAWGEnab()
12745  session.start(0)
12746  time.sleep(0.02) # wait awhile here for some reason
12747  elif session.continuous:
12748  session.end()
12749  session.flush()
12750  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z mode
12751  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z mode
12752 
12753 # ======= Spectrum Analyzer functions ===========
12754 #
12756  global CANVASwidthF, CANVASheightF, freqwindow
12757  global COLORtext
12758  # ask for file name
12759  filename = asksaveasfilename(defaultextension = ".eps", filetypes=[("Encapsulated Postscript", "*.eps")], parent=freqwindow)
12760  Orient = askyesno("Rotation","Save in Landscape (Yes) or Portrait (No):\n", parent=freqwindow)
12761  if MarkerNum > 0 or ColorMode.get() > 0:
12762  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
12763  else: # temp change text color to black
12764  COLORtext = "#000000"
12766  # save postscript file
12767  Freqca.postscript(file=filename, height=CANVASheightF, width=CANVASwidthF, colormode='color', rotate=Orient)
12768  #
12769  COLORtext = "#ffffff"
12771 #
12772 def Bnot():
12773  print( "Routine not made yet")
12774 
12776  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
12777  ShowC1_VdB.set(1)
12778  ShowC1_P.set(1)
12779  ShowC2_VdB.set(1)
12780  ShowC2_P.set(1)
12781 
12783  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P
12784  ShowC1_VdB.set(0)
12785  ShowC1_P.set(0)
12786  ShowC2_VdB.set(0)
12787  ShowC2_P.set(0)
12788 
12790  global RUNstatus
12791  global FreqTraceMode
12792 
12793  FreqTraceMode.set(1)
12794  if RUNstatus.get() == 0: # Update if stopped
12796  if RUNstatus.get() == 2: # Restart if running
12797  RUNstatus.set(4)
12798 
12800  global RUNstatus
12801  global FreqTraceMode
12802 
12803  FreqTraceMode.set(2)
12804  if RUNstatus.get() == 0: # Update if stopped
12806  if RUNstatus.get() == 2: # Restart if running
12807  RUNstatus.set(4)
12808 
12810  global RUNstatus, TRACEaverage, FreqTraceMode, freqwindow
12811 
12812  FreqTraceMode.set(3)
12813 
12814  if RUNstatus.get() == 0: # Update if stopped
12816  if RUNstatus.get() == 2: # Restart if running
12817  RUNstatus.set(4)
12818 
12820  global FreqTraceMode, TRACEresetFreq
12821 
12822  if FreqTraceMode.get()==3:
12823  TRACEresetFreq = True
12824 
12826  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
12827  global T1Fline, T2Fline, T1FRline, T2FRline, TFRMline, TFMline
12828  global T1Pline, T2Pline, T1PRline, T2PRline
12829  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12830  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12831  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12832  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12833  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12834 
12835  if ShowC1_VdB.get() == 1:
12836  T1FRline = T1Fline
12837  PeakxRA = PeakxA
12838  PeakyRA = PeakyA
12839  PeakdbRA = PeakdbA
12840  PeakfreqRA = PeakfreqA
12841  if ShowC2_VdB.get() == 1:
12842  T2FRline = T2Fline
12843  PeakxRB = PeakxB
12844  PeakyRB = PeakyB
12845  PeakdbRB = PeakdbB
12846  PeakfreqRB = PeakfreqB
12847  if ShowC1_P.get() == 1:
12848  T1PRline = T1Pline
12849  if ShowC2_P.get() == 1:
12850  T2PRline = T2Pline
12851  if ShowMathSA.get() > 0:
12852  TFRMline = TFMline
12853  PeakxRM = PeakxM
12854  PeakyRM = PeakyM
12855  PeakRMdb = PeakMdb
12856  PeakfreqRM = PeakfreqM
12857 
12858  UpdateFreqTrace() # Always Update
12859 #
12861  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
12862  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
12863  global TAFline, TBFline, TAFRline, TBFRline, TBPRMline, TBPMline
12864  global TAPline, TBPline, TAPRline, TBPRline
12865  global TIARline, TIAXline, TIAMagline, TIAAngline
12866  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
12867  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
12868  global PeakxM, PeakyM, PeakMdb, PeakfreqM
12869  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
12870  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
12871  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
12872 
12873  if ShowCA_VdB.get() == 1:
12874  TAFRline = TAFline
12875  PeakxRA = PeakxA
12876  PeakyRA = PeakyA
12877  PeakdbRA = PeakdbA
12878  PeakfreqRA = PeakfreqA
12879  if ShowCB_VdB.get() == 1:
12880  TBFRline = TBFline
12881  PeakxRB = PeakxB
12882  PeakyRB = PeakyB
12883  PeakdbRB = PeakdbB
12884  PeakfreqRB = PeakfreqB
12885  if ShowCA_P.get() == 1:
12886  TAPRline = TAPline
12887  if ShowCB_P.get() == 1:
12888  TBPRline = TBPline
12889  if ShowMathBP.get() > 0:
12890  TBPRMline = TBPMline
12891  PeakxRM = PeakxM
12892  PeakyRM = PeakyM
12893  PeakRMdb = PeakMdb
12894  PeakfreqRM = PeakfreqM
12895  if Show_Rseries.get() > 0:
12896  RefIARline = TIARline
12897  if Show_Xseries.get() > 0:
12898  RefIAXline = TIAXline
12899  if Show_Magnitude.get() > 0:
12900  RefIAMagline = TIAMagline
12901  if Show_Angle.get() > 0:
12902  RefIAAngline = TIAAngline
12903  UpdateBodeTrace() # Always Update
12904 #
12905 def BCSVfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
12906  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins, bodewindow
12907  global SAMPLErate, ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
12908 
12909  # Set the TRACEsize variable
12910  if ShowCA_VdB.get() == 1:
12911  TRACEsize = len(FSweepAdB) # Set the trace length
12912  elif ShowCA_VdB.get() == 1:
12913  TRACEsize = len(FSweepBdB)
12914  if TRACEsize == 0: # If no trace, skip rest of this routine
12915  return()
12916 # ask if save as magnitude or dB
12917  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=bodewindow)
12918 # Yes 1 = dB, No 0 = Mag
12919  # Make the file name and open it
12920  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
12921  filename = "Bode-" + tme
12922  filename = filename + ".csv"
12923  # open file to save data
12924  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
12925  filetypes=[("Comma Separated Values", "*.csv")], parent=bodewindow)
12926  DataFile = open(filename,'a') # Open output file
12927  HeaderString = 'Frequency-#, '
12928  if ShowCA_VdB.get() == 1:
12929  if dB == 1:
12930  HeaderString = HeaderString + 'CA-dB, '
12931  if dB == 0:
12932  HeaderString = HeaderString + 'CA-Mag, '
12933  if ShowCB_VdB.get() == 1:
12934  if dB == 1:
12935  HeaderString = HeaderString + 'CB-dB, '
12936  if dB == 0:
12937  HeaderString = HeaderString + 'CB-Mag, '
12938  if ShowCA_P.get() == 1:
12939  HeaderString = HeaderString + 'Phase A-B, '
12940  if ShowCB_P.get() == 1:
12941  HeaderString = HeaderString + 'Phase B-A, '
12942  HeaderString = HeaderString + '\n'
12943  DataFile.write( HeaderString )
12944 
12945  n = 0
12946  while n < len(FSweepAdB):
12947  F = FBins[FStep[n]] # look up frequency bin in list of bins
12948  txt = str(F)
12949  if ShowCA_VdB.get() == 1:
12950  V = 10 * math.log10(float(FSweepAdB[n]))
12951  if dB == 0:
12952  V = 10.0**(V/20.0)
12953  txt = txt + "," + str(V)
12954  if ShowCB_VdB.get() == 1:
12955  V = 10 * math.log10(float(FSweepBdB[n]))
12956  if dB == 0:
12957  V = 10.0**(V/20.0)
12958  txt = txt + "," + str(V)
12959  if ShowCA_P.get() == 1:
12960  RelPhase = FSweepAPh[n]#-FSweepBPh[n]
12961  if RelPhase > 180:
12962  RelPhase = RelPhase - 360
12963  elif RelPhase < -180:
12964  RelPhase = RelPhase + 360
12965  txt = txt + "," + str(RelPhase)
12966  if ShowCB_P.get() == 1:
12967  RelPhase = FSweepBPh[n]#-FSweepAPh[n]
12968  if RelPhase > 180:
12969  RelPhase = RelPhase - 360
12970  elif RelPhase < -180:
12971  RelPhase = RelPhase + 360
12972  txt = txt + "," + str(RelPhase)
12973  txt = txt + "\n"
12974  DataFile.write(txt)
12975  n = n + 1
12976 
12977  DataFile.close() # Close the file
12978 
12980  global iawindow, FStep, FBins
12981  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
12982 
12983  if NetworkScreenStatus.get() > 0:
12984  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
12985  filename = "Impedance-" + tme
12986  filename = filename + ".csv"
12987  # open file to save data
12988  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
12989  filetypes=[("Comma Separated Values", "*.csv")], parent=iawindow)
12990  DataFile = open(filename,'a') # Open output file
12991  HeaderString = 'Frequency, Series R, Seriec X, Series Z, Series Angle'
12992  HeaderString = HeaderString + '\n'
12993  DataFile.write( HeaderString )
12994 
12995  n = 0
12996  while n < len(NSweepSeriesR):
12997  F = FBins[FStep[n]] # look up frequency bin in list of bins
12998  txt = str(F) + "," + str(NSweepSeriesR[n]) + "," + str(NSweepSeriesX[n]) + "," + str(NSweepSeriesMag[n]) + "," + str(NSweepSeriesAng[n])
12999  txt = txt + "\n"
13000  DataFile.write(txt)
13001  n = n + 1
13002  DataFile.close() # Close the file
13003  else:
13004  return
13005 #
13006 def BStartSA():
13007  global RUNstatus, PowerStatus, devx, PwrBt, freqwindow, session, AWGSync, contloop, discontloop
13008  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA, DevID, FWRevOne, StopFreqEntry
13009  global Two_X_Sample, ADC_Mux_Mode, ShowAWGASA, ShowAWGBSA
13010 
13011  #AWGSync.set(0) # always run in continuous mode
13012  if DevID == "No Device":
13013  showwarning("WARNING","No Device Plugged In!")
13014  elif FWRevOne == 0.0:
13015  showwarning("WARNING","Out of data Firmware!")
13016  else:
13017  if PowerStatus == 0:
13018  PowerStatus = 1
13019  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13020  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13021 
13022  if (ShowC1_VdB.get() == 0 and
13023  ShowC2_VdB.get() == 0 and
13024  ShowMathSA.get() == 0 and
13025  ShowAWGASA.get() == 0 and
13026  ShowAWGBSA.get() == 0 and
13027  ShowC1_P.get() == 0 and
13028  ShowC2_P.get() == 0):
13029  showwarning("WARNING","Select at least one trace first", parent=freqwindow)
13030  return()
13031  try:
13032  StopFrequency = float(StopFreqEntry.get())
13033  except:
13034  StopFreqEntry.delete(0,"end")
13035  StopFreqEntry.insert(0,50000)
13036  StopFrequency = 50000
13037  if FWRevOne > 2.16:
13038  if StopFrequency >= 50000:
13039  Two_X_Sample.set(1)
13040  else:
13041  Two_X_Sample.set(0)
13042  ADC_Mux_Mode.set(0)
13043  SetADC_Mux()
13044  #
13045  BStart()
13046 #
13047  UpdateFreqAll() # Always Update
13048 
13049 def BStopSA():
13050  global RUNstatus, session, AWGSync
13051 
13052  if (RUNstatus.get() == 1):
13053  RUNstatus.set(0)
13054  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
13055  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
13056  if AWGSync.get() == 0: # running in continuous mode
13057  CHA.constant(0.0)
13058  CHB.constant(0.0)
13059  # print "Stoping continuous mode"
13060  if session.continuous:
13061  # print "Stoping Is Continuous? ", session.continuous
13062  time.sleep(0.02)
13063  #print "Is Continuous? ", session.continuous
13064  else:
13065  contloop = 0
13066  discontloop = 1
13067  session.cancel()
13068  elif (RUNstatus.get() == 2):
13069  RUNstatus.set(3)
13070  elif (RUNstatus.get() == 3):
13071  RUNstatus.set(3)
13072  elif (RUNstatus.get() == 4):
13073  RUNstatus.set(3)
13074  UpdateFreqAll() # Always Update
13075 
13076 def Blevel1():
13077  global DBlevel
13078  global RUNstatus
13079 
13080  DBlevel.set(DBlevel.get() - 1)
13081 
13082  if RUNstatus.get() == 0: # Update if stopped
13083  UpdateFreqTrace()
13084 
13085 def Blevel2():
13086  global DBlevel
13087  global RUNstatus
13088 
13089  DBlevel.set(DBlevel.get() + 1)
13090 
13091  if RUNstatus.get() == 0: # Update if stopped
13092  UpdateFreqTrace()
13093 
13094 def Blevel3():
13095  global DBlevel
13096  global RUNstatus
13097 
13098  DBlevel.set(DBlevel.get() - 10)
13099 
13100  if RUNstatus.get() == 0: # Update if stopped
13101  UpdateFreqTrace()
13102 
13103 def Blevel4():
13104  global DBlevel
13105  global RUNstatus
13106 
13107  DBlevel.set(DBlevel.get() + 10)
13108 
13109  if RUNstatus.get() == 0: # Update if stopped
13110  UpdateFreqTrace()
13111 #
13113  global RUNstatus, SpectrumScreenStatus, IAScreenStatus
13114  global SMPfftpwrTwo, SMPfft, FFTwindow
13115  global TRACEresetFreq, PhAScreenStatus
13116 
13117  if FFTwindow.get() != 8:
13118  if (SMPfftpwrTwo.get() > 6): # Min 64
13119  SMPfftpwrTwo.set(SMPfftpwrTwo.get() - 1)
13120  TRACEresetFreq = True # Reset trace peak and trace average
13121  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13122 
13123  if RUNstatus.get() == 0: # Update if stopped
13124  if SpectrumScreenStatus.get() > 0:
13126  if IAScreenStatus.get() > 0:
13127  UpdateIAScreen()
13128  if PhAScreenStatus.get() > 0:
13129  UpdatePhAScreen()
13130  if RUNstatus.get() == 2: # Restart if running
13131  RUNstatus.set(4)
13132 
13134  global RUNstatus, PhAScreenStatus
13135  global SMPfftpwrTwo, SMPfft, FFTwindow
13136  global TRACEresetFreq, SpectrumScreenStatus, IAScreenStatus
13137 
13138  if FFTwindow.get() != 8:
13139  if (SMPfftpwrTwo.get() < 16): # Max 65536
13140  SMPfftpwrTwo.set(SMPfftpwrTwo.get() + 1)
13141  TRACEresetFREQ = True # Reset trace peak and trace average
13142  SMPfft = 2 ** int(SMPfftpwrTwo.get())
13143 
13144  if RUNstatus.get() == 0: # Update if stopped
13145  if SpectrumScreenStatus.get() > 0:
13147  if IAScreenStatus.get() > 0:
13148  UpdateIAScreen()
13149  if PhAScreenStatus.get() > 0:
13150  UpdatePhAScreen()
13151  if RUNstatus.get() == 2: # Restart if running
13152  RUNstatus.set(4)
13153 
13154 def BDBdiv1():
13155  global DBdivindex
13156  global RUNstatus
13157 
13158  if (DBdivindex.get() >= 1):
13159  DBdivindex.set(DBdivindex.get() - 1)
13160 
13161  if RUNstatus.get() == 0: # Update if stopped
13162  UpdateFreqTrace()
13163 
13164 def BDBdiv2():
13165  global DBdivindex
13166  global DBdivlist
13167  global RUNstatus
13168 
13169  if (DBdivindex.get() < len(DBdivlist) - 1):
13170  DBdivindex.set(DBdivindex.get() + 1)
13171 
13172  if RUNstatus.get() == 0: # Update if stopped
13173  UpdateFreqTrace()
13174 #----- Bode Plot controls
13175 def BStartBP():
13176  global RUNstatus, LoopNum, PowerStatus, devx, PwrBt, bodewindow, session, AWGSync
13177  global ShowCA_VdB, ShowCB_P, ShowCB_VdB, ShowCB_P, ShowMathBP, contloop, discontloop
13178  global FBins, FStep, NSteps, FSweepMode, HScaleBP, CutDC
13179  global AWGAMode, AWGAShape, AWGBMode, AWGBShape
13180  global StartBodeEntry, StopBodeEntry, SweepStepBodeEntry, DevID, FWRevOne
13181  global AWGAFreqEntry, AWGBFreqEntry, Reset_Freq, AWGAIOMode, AWGBIOMode
13182  global Two_X_Sample, ADC_Mux_Mode, AWG_2X, ZEROstuffing, SAMPLErate
13183  global BeginIndex, EndIndex
13184 
13185  if DevID == "No Device":
13186  showwarning("WARNING","No Device Plugged In!")
13187  elif FWRevOne == 0.0:
13188  showwarning("WARNING","Out of data Firmware!")
13189  else:
13190  if PowerStatus == 0:
13191  PowerStatus = 1
13192  PwrBt.config(style="Pwr.TButton",text="PWR-On")
13193  devx.ctrl_transfer( 0x40, 0x51, 49, 0, 0, 0, 100) # turn on analog power
13194 
13195  if ShowCA_VdB.get() == 0 and ShowCB_VdB.get() == 0 and ShowMathBP.get() == 0:
13196  showwarning("WARNING","Select at least one trace first", parent=bodewindow)
13197  return()
13198  #
13199  if ZEROstuffing.get() < 3:
13200  ZEROstuffing.set(3)
13201  CutDC.set(1) # set to remove DC
13202  try:
13203  EndFreq = float(StopBodeEntry.get())
13204  except:
13205  StopBodeEntry.delete(0,"end")
13206  StopBodeEntry.insert(0,10000)
13207  EndFreq = 10000
13208  if FWRevOne > 2.16:
13209  if EndFreq >= 20000:
13210  Two_X_Sample.set(1)
13211  FBins = numpy.linspace(0, 100000, num=16384)
13212  else:
13213  Two_X_Sample.set(0)
13214  FBins = numpy.linspace(0, 50000, num=16384)
13215  ADC_Mux_Mode.set(0)
13216  SetADC_Mux()
13217  try:
13218  BeginFreq = float(StartBodeEntry.get())
13219  except:
13220  StartBodeEntry.delete(0,"end")
13221  StartBodeEntry.insert(0,100)
13222  BeginFreq = 100
13223  #
13224  if FSweepMode.get() == 1:
13225  if AWGAMode.get() == 2:
13226  AWGAMode.set(0) # Set AWG A to SVMI
13227  AWGAShape.set(18) # Set Shape to Sine
13228  if Two_X_Sample.get() == 1:
13229  AWGBIOMode.set(1)
13230  AWGBMode.set(0)
13231  else:
13232  AWGBMode.set(2) # Set AWG B to Hi-Z
13233  AWG_2X.set(0)
13234  BAWG2X()
13235  Reset_Freq = AWGAFreqEntry.get()
13236  if FSweepMode.get() == 2:
13237  if AWGBMode.get() == 2:
13238  AWGBMode.set(0) # Set AWG B to SVMI
13239  AWGBShape.set(18) # Set Shape to Sine
13240  if Two_X_Sample.get() == 1:
13241  AWGAIOMode.set(1)
13242  AWGAMode.set(0)
13243  else:
13244  AWGAMode.set(2) # Set AWG A to Hi-Z
13245  AWG_2X.set(0)
13246  BAWG2X()
13247  Reset_Freq = AWGBFreqEntry.get()
13248  if FSweepMode.get() == 3: # using external Minigen
13249  AWGAMode.set(2) # Set AWG A to Hi-Z
13250  AWGBMode.set(2) # Set AWG B to Hi-Z
13251  try:
13252  NSteps.set(float(SweepStepBodeEntry.get()))
13253  except:
13254  SweepStepBodeEntry.delete(0,"end")
13255  SweepStepBodeEntry.insert(0, NSteps.get())
13256  #
13257  if FSweepMode.get() > 0:
13258  BAWGAModeLabel() # make sure AWG screen labels reflect any changes to the modes
13259  BAWGBModeLabel()
13260  LoopNum.set(1)
13261  NyquistFreq = SAMPLErate/2
13262  BeginIndex = int((BeginFreq/NyquistFreq)*16384)
13263  EndIndex = int((EndFreq/NyquistFreq)*16384)
13264  if NSteps.get() < 5:
13265  NSteps.set(5)
13266  if HScaleBP.get() == 1:
13267  LogFStop = math.log10(EndIndex)
13268  try:
13269  LogFStart = math.log10(BeginIndex)
13270  except:
13271  LogFStart = 1.0
13272  FStep = numpy.logspace(LogFStart, LogFStop, num=NSteps.get(), base=10.0)
13273  else:
13274  FStep = numpy.linspace(BeginIndex, EndIndex, num=NSteps.get())
13275  BStart()
13276  # UpdateBodeAll() # Always Update
13277 #
13278 def BStopBP():
13279  global RUNstatus, session, AWGSync, FSweepMode, AWGAFreqEntry, AWGBFreqEntry, Reset_Freq
13280 
13281  if FSweepMode.get() == 1:
13282  AWGAFreqEntry.delete(0,"end")
13283  AWGAFreqEntry.insert(0, Reset_Freq)
13284  if FSweepMode.get() == 2:
13285  AWGBFreqEntry.delete(0,"end")
13286  AWGBFreqEntry.insert(0, Reset_Freq)
13287 #
13288  if (RUNstatus.get() == 1):
13289  RUNstatus.set(0)
13290  if AWGSync.get() == 0: # running in continuous mode
13291  session.cancel() # cancel continuous session mode while paused
13292  elif (RUNstatus.get() == 2):
13293  RUNstatus.set(3)
13294  elif (RUNstatus.get() == 3):
13295  RUNstatus.set(3)
13296  elif (RUNstatus.get() == 4):
13297  RUNstatus.set(3)
13298  UpdateBodeAll() # Always Update
13299 #
13301  global DBlevelBP
13302  global RUNstatus
13303 
13304  DBlevelBP.set(DBlevelBP.get() - 1)
13305 
13306  if RUNstatus.get() == 0: # Update if stopped
13307  UpdateBodeTrace()
13308 
13310  global DBlevelBP
13311  global RUNstatus
13312 
13313  DBlevelBP.set(DBlevelBP.get() + 1)
13314 
13315  if RUNstatus.get() == 0: # Update if stopped
13316  UpdateBodeTrace()
13317 
13319  global DBlevelBP
13320  global RUNstatus
13321 
13322  DBlevelBP.set(DBlevelBP.get() - 10)
13323 
13324  if RUNstatus.get() == 0: # Update if stopped
13325  UpdateBodeTrace()
13326 
13328  global DBlevelBP
13329  global RUNstatus
13330 
13331  DBlevelBP.set(DBlevelBP.get() + 10)
13332 
13333  if RUNstatus.get() == 0: # Update if stopped
13334  UpdateBodeTrace()
13335 
13337  global DBdivindexBP
13338  global RUNstatus
13339 
13340  if (DBdivindexBP.get() >= 1):
13341  DBdivindexBP.set(DBdivindexBP.get() - 1)
13342 
13343  if RUNstatus.get() == 0: # Update if stopped
13344  UpdateBodeTrace()
13345 
13347  global DBdivindexBP
13348  global DBdivlist
13349  global RUNstatus
13350 
13351  if (DBdivindexBP.get() < len(DBdivlist) - 1):
13352  DBdivindexBP.set(DBdivindexBP.get() + 1)
13353 
13354  if RUNstatus.get() == 0: # Update if stopped
13355  UpdateBodeTrace()
13356 #
13358  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
13359  ShowCA_VdB.set(1)
13360  ShowCA_P.set(1)
13361  ShowCB_VdB.set(1)
13362  ShowCB_P.set(1)
13363 
13365  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P
13366  ShowCA_VdB.set(0)
13367  ShowCA_P.set(0)
13368  ShowCB_VdB.set(0)
13369  ShowCB_P.set(0)
13370 # Bode Plot refresh
13371 def UpdateBodeAll(): # Update Data, trace and screen
13372  global FFTBuffA, FFTBuffB
13373  global SMPfft
13374 
13375  # DoFFT() # Fast Fourier transformation
13376  MakeBodeTrace() # Update the traces
13377  UpdateBodeScreen() # Update the screen
13378 
13379 def UpdateBodeTrace(): # Update trace and screen
13380  MakeBodeTrace() # Update traces
13381  UpdateBodeScreen() # Update the screen
13382 
13383 def UpdateBodeScreen(): # Update screen with trace and text
13384  MakeBodeScreen() # Update the screen
13385 
13386 # ============================================ Freq Main routine ====================================================
13387 
13388 def UpdateFreqAll(): # Update Data, trace and screen
13389  global FFTBuffA, FFTBuffB
13390  global SMPfft
13391 
13392  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
13393  return
13394 
13395  # DoFFT() # Fast Fourier transformation
13396  MakeFreqTrace() # Update the traces
13397  UpdateFreqScreen() # Update the screen
13398 
13399 def UpdateFreqTrace(): # Update trace and screen
13400  MakeFreqTrace() # Update traces
13401  UpdateFreqScreen() # Update the screen
13402 
13403 def UpdateFreqScreen(): # Update screen with trace and text
13404  MakeFreqScreen() # Update the screen
13405 
13406 def DoFFT(): # Fast Fourier transformation
13407  global FFTBuffA, FFTBuffB, AWGAwaveform, AWGBwaveform
13408  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowAWGASA, ShowAWGBSA
13409  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
13410  global FFTmemoryB, FFTresultB, FFTresultAWGA, FFTresultAWGB
13411  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh
13412  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
13413  global FFTwindowshape, FFTbandwidth
13414  global AWGSAMPLErate, StartFreqEntry, StopFreqEntry, StartBodeEntry
13415  global SMPfft, LoopNum, IA_Ext_Conf
13416  global STARTsample, STOPsample, CutDC
13417  global TRACEaverage, FreqTraceMode, FSweepMode
13418  global TRACEresetFreq, ZEROstuffing
13419  global SpectrumScreenStatus, IAScreenStatus, BodeScreenStatus
13420  global NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
13421  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesL
13422 
13423  # T1 = time.time() # For time measurement of FFT routine
13424  REX = []
13425  PhaseA = []
13426  PhaseB = []
13427  # Convert list to numpy array REX for faster Numpy calculations
13428  # Take the first fft samples
13429  REX = numpy.array(FFTBuffA[0:SMPfft]) # Make a numpy arry of the list
13430 
13431  # Set Analog level display value MAX value is 5 volts for ALM1000
13432  REX = REX / 5.0
13433 
13434  # Do the FFT window function
13435  REX = REX * FFTwindowshape[0:len(REX)] # The windowing shape function only over the samples
13436 
13437  # Zero stuffing of array for better interpolation of peak level of signals
13438  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13439  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13440 
13441  # Save previous trace in memory for max or average trace
13442  FFTmemoryA = FFTresultA
13443  if FreqTraceMode.get() == 3:
13444  PhaseMemoryA = PhaseA
13445 
13446  # FFT with numpy
13447  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13448  PhaseA = numpy.angle(ALL, deg=True) # calculate angle
13449  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13450  ALL = ALL * ALL # Convert from Voltage to Power (P = (V*V) / R; R = 1)
13451 
13452  le = int(len(ALL) / 2) # Only half is used, other half is mirror
13453  # ALL = ALL[0:le] # So take only first half of the array
13454  FFTresultA = ALL[0:le]
13455  PhaseA = PhaseA[0:le]
13456  RMScorr = 1.0 / SMPfft # For VOLTAGE!
13457  Powcorr = 50*(RMScorr **2) # vpktage squared For POWER!
13458  FFTresultA = FFTresultA * Powcorr
13459 #
13460  REX = []
13461  # Convert list to numpy array REX for faster Numpy calculations
13462  # Take the first fft samples
13463  REX = numpy.array(FFTBuffB[0:SMPfft]) # Make a numpy arry of the list
13464 
13465  # Set level display value MAX value is 5 volts for ALM1000
13466  REX = REX / 5.0
13467 
13468  # Do the FFT window function
13469  try:
13470  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13471  except:
13472  return
13473  # Zero stuffing of array for better interpolation of peak level of signals
13474  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13475  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13476 
13477  # Save previous trace in memory for max or average trace
13478  FFTmemoryB = FFTresultB
13479  if FreqTraceMode.get() == 3:
13480  PhaseMemoryB = PhaseB
13481  # FFT with numpy
13482  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13483  PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13484  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13485  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13486 
13487  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13488  # ALL = ALL[0:le] # So take only first half of the array
13489  FFTresultB = ALL[0:le]
13490  PhaseB = PhaseB[0:le]
13491  FFTresultB = FFTresultB * Powcorr
13492 #
13493  if IA_Ext_Conf.get() == 1: # calculate fft for voltage A-B for use if IA set to config 2
13494  REX = []
13495  PhaseAB = []
13496  # Convert list to numpy array REX for faster Numpy calculations
13497  # Take the first fft samples
13498  REX = numpy.array(FFTBuffA[0:SMPfft]-FFTBuffB[0:SMPfft]) # Make a numpy arry of the VA-VB list
13499 
13500  # Set level display value MAX value is 5 volts for ALM1000
13501  REX = REX / 5.0
13502 
13503  # Do the FFT window function
13504  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13505 
13506  # Zero stuffing of array for better interpolation of peak level of signals
13507  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13508  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13509 
13510  # Save previous trace in memory for max or average trace
13511  # FFTmemoryB = FFTresultB
13512  # if FreqTraceMode.get() == 3:
13513  # PhaseMemoryB = PhaseB
13514  # FFT with numpy
13515  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13516  PhaseAB = numpy.angle(ALL, deg=True) # calculate angle
13517  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13518  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13519 
13520  le = len(ALL) / 2 # Only half is used, other half is mirror
13521  #ALL = ALL[:le] # So take only first half of the array
13522  FFTresultAB = ALL[:le]
13523  PhaseAB = PhaseAB[:le]
13524  FFTresultAB = FFTresultAB * Powcorr
13525 #
13526  if ShowAWGASA.get() > 0:
13527  FFTAWGA = AWGAwaveform
13528  DCA = 0.0
13529  if CutDC.get() == 1:
13530  DCA = numpy.average(FFTAWGA)
13531  FFTAWGA = FFTAWGA - DCA
13532  if len(AWGAwaveform) < SMPfft:
13533  Repeats = math.ceil(SMPfft/len(AWGAwaveform))
13534  i = 0
13535  while i < Repeats:
13536  FFTAWGA = numpy.concatenate((FFTAWGA, AWGAwaveform-DCA))
13537  i = i + 1
13538  REX = []
13539  # Convert list to numpy array REX for faster Numpy calculations
13540  # Take the first fft samples
13541  REX = numpy.array(FFTAWGA[0:SMPfft]) # Make a numpy arry of the list
13542 
13543  # Set level display value MAX value is 5 volts for ALM1000
13544  REX = REX / 5.0
13545 
13546  # Do the FFT window function
13547  try:
13548  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13549  except:
13550  return
13551  # Zero stuffing of array for better interpolation of peak level of signals
13552  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13553  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13554  # FFT with numpy
13555  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13556  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13557  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13558  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13559 
13560  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13561  # ALL = ALL[0:le] # So take only first half of the array
13562  FFTresultAWGA = ALL[0:le]
13563  #PhaseB = PhaseB[0:le]
13564  FFTresultAWGA = FFTresultAWGA * Powcorr
13565 #
13566  if ShowAWGBSA.get() > 0:
13567  FFTAWGB = AWGBwaveform
13568  DCB = 0.0
13569  if CutDC.get() == 1:
13570  DCB = numpy.average(FFTAWGB)
13571  FFTAWGB = FFTAWGB - DCB
13572  if len(AWGBwaveform) < SMPfft:
13573  Repeats = math.ceil(SMPfft/len(AWGBwaveform))
13574  i = 1
13575  while i < Repeats:
13576  FFTAWGB = numpy.concatenate((FFTAWGB, AWGBwaveform-DCB))
13577  i = i + 1
13578  REX = []
13579  # Convert list to numpy array REX for faster Numpy calculations
13580  # Take the first fft samples
13581  REX = numpy.array(FFTAWGB[0:SMPfft]) # Make a numpy arry of the list
13582 
13583  # Set level display value MAX value is 5 volts for ALM1000
13584  REX = REX / 5.0
13585 
13586  # Do the FFT window function
13587  try:
13588  REX = REX * FFTwindowshape # The windowing shape function only over the samples
13589  except:
13590  return
13591  # Zero stuffing of array for better interpolation of peak level of signals
13592  ZEROstuffingvalue = int(2 ** ZEROstuffing.get())
13593  fftsamples = ZEROstuffingvalue * SMPfft # Add zero's to the arrays
13594  # FFT with numpy
13595  ALL = numpy.fft.fft(REX, n=fftsamples) # Do FFT + zerostuffing till n=fftsamples with NUMPY ALL = Real + Imaginary part
13596  #PhaseB = numpy.angle(ALL, deg=True) # calculate angle
13597  ALL = numpy.absolute(ALL) # Make absolute SQR(REX*REX + IMX*IMX) for VOLTAGE!
13598  ALL = ALL * ALL # Convert from Voltage to Power (P = (U*U) / R; R = 1)
13599 
13600  le = int(len(ALL) / 2 ) # Only half is used, other half is mirror
13601  #ALL = ALL[0:le] # So take only first half of the array
13602  FFTresultAWGB = ALL[0:le]
13603  #PhaseB = PhaseB[0:le]
13604  FFTresultAWGB = FFTresultAWGB * Powcorr
13605 #
13606  TRACEsize = int(len(FFTresultB))
13607  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
13608  if SpectrumScreenStatus.get() > 0:
13609  try:
13610  StartFrequency = float(StartFreqEntry.get())
13611  except:
13612  StartFreqEntry.delete(0,"end")
13613  StartFreqEntry.insert(0,100)
13614  StartFrequency = 100
13615  STARTsample = int(StartFrequency / Fsample)
13616  else:
13617  STARTsample = 0
13618  if LoopNum.get() == 1:
13619  PhaseMemoryB = PhaseB
13620  FSweepAdB = []
13621  FSweepBdB = []
13622  FSweepAPh = []
13623  FSweepBPh = []
13624  if NetworkScreenStatus.get() > 0:
13625  NSweepSeriesR = []
13626  NSweepSeriesX = []
13627  NSweepSeriesMag = [] # in ohms
13628  NSweepSeriesAng = [] # in degrees
13629  NSweepParallelR = []
13630  NSweepParallelC = []
13631  NSweepParallelL = []
13632  NSweepSeriesC = []
13633  NSweepSeriesL = []
13634  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
13635  if FSweepMode.get() == 1:
13636  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13637  if ptmax > STARTsample:
13638  STARTsample = ptmax
13639  i = 0
13640  while i < 6:
13641  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13642  i = i + 1
13643  if FSweepMode.get() == 2:
13644  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13645  if ptmax > STARTsample:
13646  STARTsample = ptmax
13647  i = 0
13648  while i < 6:
13649  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13650  i = i + 1
13651 
13652  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
13653  if FSweepMode.get() == 1:
13654  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13655  if ptmax > STARTsample:
13656  STARTsample = ptmax
13657  i = 0
13658  while i < 6:
13659  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13660  i = i + 1
13661  if FSweepMode.get() == 2:
13662  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13663  if ptmax > STARTsample:
13664  STARTsample = ptmax
13665  i = 0
13666  while i < 6:
13667  PhaseMemoryB[ptmax+i] = PhaseB[ptmax]
13668  i = i + 1
13669  if len(FFTresultB) == len(FFTmemoryB):
13670  FFTresultB = numpy.maximum(FFTresultB, FFTmemoryB)#
13671  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
13672  try:
13673  FFTresultB = FFTmemoryB + (FFTresultB - FFTmemoryB) / TRACEaverage.get()
13674  PhaseB = PhaseMemoryB +(PhaseB - PhaseMemoryB) / TRACEaverage.get()
13675  except:
13676  FFTmemoryB = FFTresultB
13677  PhaseMemoryB = PhaseB
13678 #
13679  TRACEsize = int(len(FFTresultA))
13680  Fsample = float(AWGSAMPLErate / 2) / (TRACEsize - 1)
13681  if SpectrumScreenStatus.get() > 0:
13682  STARTsample = int(StartFrequency / Fsample)
13683  else:
13684  STARTsample = 0
13685  if LoopNum.get() == 1:
13686  PhaseMemoryA = PhaseA
13687  if FreqTraceMode.get() == 1: # Normal mode 1, do not change
13688  if FSweepMode.get() == 1:
13689  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13690  if ptmax > STARTsample:
13691  STARTsample = ptmax
13692  i = 0
13693  while i < 6:
13694  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13695  i = i + 1
13696  if FSweepMode.get() == 2:
13697  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13698  if ptmax > STARTsample:
13699  STARTsample = ptmax
13700  i = 0
13701  while i < 6:
13702  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13703  i = i + 1
13704 
13705  if FreqTraceMode.get() == 2 and TRACEresetFreq == False: # Peak hold mode 2, change v to peak value
13706  if FSweepMode.get() == 1:
13707  ptmax = numpy.argmax(FFTresultA[STARTsample:TRACEsize])
13708  if ptmax > STARTsample:
13709  STARTsample = ptmax
13710  i = 0
13711  while i < 6:
13712  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13713  i = i + 1
13714  if FSweepMode.get() == 2:
13715  ptmax = numpy.argmax(FFTresultB[STARTsample:TRACEsize])
13716  if ptmax > STARTsample:
13717  STARTsample = ptmax
13718  i = 0
13719  while i < 6:
13720  PhaseMemoryA[ptmax+i] = PhaseA[ptmax]
13721  i = i + 1
13722 #
13723  if len(FFTresultA) == len(FFTmemoryA):
13724  FFTresultA = numpy.maximum(FFTresultA, FFTmemoryA)
13725  if FreqTraceMode.get() == 3 and TRACEresetFreq == False: # Average mode 3, add difference / TRACEaverage to v
13726  try:
13727  FFTresultA = FFTmemoryA + (FFTresultA - FFTmemoryA) / TRACEaverage.get()
13728  PhaseA = PhaseMemoryA +(PhaseA - PhaseMemoryA) / TRACEaverage.get()
13729  except:
13730  FFTmemoryA = FFTresultA
13731  PhaseMemoryA = PhaseA
13732 #
13733  if FSweepMode.get() > 0 and BodeScreenStatus.get() > 0:
13734  FSweepAdB.append(numpy.amax(FFTresultA))
13735  FSweepBdB.append(numpy.amax(FFTresultB))
13736  FSweepAPh.append(PhaseA[numpy.argmax(FFTresultA)])
13737  FSweepBPh.append(PhaseB[numpy.argmax(FFTresultB)])
13738 
13739  TRACEresetFreq = False # Trace reset done
13740 
13741 def MakeFreqTrace(): # Update the grid and trace
13742  global FFTmemoryA, FFTresultA
13743  global FFTmemoryB, FFTresultB
13744  global FFTresultAWGA, FFTresultAWGB, ShowAWGASA, ShowAWGBSA
13745  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
13746  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep
13747  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMathSA
13748  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
13749  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakIndexA, PeakIndexB
13750  global PeakfreqA, PeakfreqB, Two_X_Sample
13751  global DBdivindex # Index value
13752  global DBdivlist # dB per division list
13753  global DBlevel # Reference level
13754  global GRHF,GRWF # Screenheight, Screenwidth
13755  global AWGSAMPLErate, HScale, Fsample, SAMPLErate, BaseSampleRate
13756  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
13757  global STARTsample, STOPsample, LoopNum, FSweepMode, FreqTraceMode, SMPfft
13758  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
13759  global T1Fline, T2Fline, TFMline, T1Pline, T2Pline, TAFline, TBFline
13760  global Vdiv # Number of vertical divisions
13761  global X0LF, Y0TF # Left top X value, Left top Y value
13762 
13763  # Set the TRACEsize variable
13764  TRACEsize = 0
13765  try:
13766  StartFrequency = float(StartFreqEntry.get())
13767  except:
13768  StartFreqEntry.delete(0,"end")
13769  StartFreqEntry.insert(0,100)
13770  StartFrequency = 100
13771  try:
13772  StopFrequency = float(StopFreqEntry.get())
13773  except:
13774  StopFreqEntry.delete(0,"end")
13775  StopFreqEntry.insert(0,50000)
13776  StopFrequency = 50000
13777  if StartFrequency > StopFrequency :
13778  StopFreqEntry.delete(0,"end")
13779  StopFreqEntry.insert(0,50000)
13780  StopFrequency = 50000
13781  if StopFrequency < StartFrequency :
13782  StopFreqEntry.delete(0,"end")
13783  StopFreqEntry.insert(0,50000)
13784  StopFrequency = 50000
13785  try:
13786  Phasecenter = int(PhCenFreqEntry.get())
13787  RelPhaseCenter.set(Phasecenter)
13788  except:
13789  PhCenFreqEntry.delete(0,"end")
13790  PhCenFreqEntry.insert(0,0)
13791  RelPhaseCenter.set(0)
13792  Phasecenter = 0
13793  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
13794  if SAvertmaxEntry.get() == "10.0":
13795  SAvertmax = 10.0
13796  elif SAvertmaxEntry.get() == "1.0":
13797  SAvertmax = 1.0
13798  elif SAvertmaxEntry.get() == "0.1":
13799  SAvertmax = 0.1
13800  elif SAvertmaxEntry.get() == "10mV":
13801  SAvertmax = 1.0E-2
13802  elif SAvertmaxEntry.get() == "1mV":
13803  SAvertmax = 1.0E-3
13804  elif SAvertmaxEntry.get() == "100uV":
13805  SAvertmax = 1.0E-4
13806  elif SAvertmaxEntry.get() == "10uV":
13807  SAvertmax = 1.0E-5
13808  elif SAvertmaxEntry.get() == "1uV":
13809  SAvertmax = 1.0E-6
13810  elif SAvertmaxEntry.get() == "100nV":
13811  SAvertmax = 1.0E-7
13812  elif SAvertmaxEntry.get() == "10nV":
13813  SAvertmax = 1.0E-8
13814  else:
13815  SAvertmax = float(SAvertmaxEntry.get())
13816  if SAvertmax < 0.0: # negative values not allowed
13817  SAvertmaxEntry.delete(0,"end")
13818  SAvertmaxEntry.insert(0, "1mV")
13819  SAvertmax = 1.0E-3
13820  except:
13821  SAvertmaxEntry.delete(0,"end")
13822  SAvertmaxEntry.insert(0, "1mV")
13823  SAvertmax = 1.0E-3
13824  try: # from list ("10.0", "1.0" , "0.1", "10mV", "1mV", "100uV", "10uV", "1uV", "100nV" , "10nV")
13825  if SAvertminEntry.get() == "10.0":
13826  SAvertmin = 10.0
13827  elif SAvertminEntry.get() == "1.0":
13828  SAvertmin = 1.0
13829  elif SAvertminEntry.get() == "0.1":
13830  SAvertmin = 0.1
13831  elif SAvertminEntry.get() == "10mV":
13832  SAvertmin = 1.0E-2
13833  elif SAvertminEntry.get() == "1mV":
13834  SAvertmin = 1.0E-3
13835  elif SAvertminEntry.get() == "100uV":
13836  SAvertmin = 1.0E-4
13837  elif SAvertminEntry.get() == "10uV":
13838  SAvertmin = 1.0E-5
13839  elif SAvertminEntry.get() == "1uV":
13840  SAvertmin = 1.0E-6
13841  elif SAvertminEntry.get() == "100nV":
13842  SAvertmin = 1.0E-7
13843  elif SAvertminEntry.get() == "10nV":
13844  SAvertmin = 1.0E-8
13845  else:
13846  SAvertmin = float(SAvertminEntry.get())
13847  if SAvertmin < 0.0: # negative values not allowed
13848  SAvertminEntry.delete(0,"end")
13849  SAvertminEntry.insert(0, "1uV")
13850  SAvertmin = 1.0E-6
13851  except:
13852  SAvertminEntry.delete(0,"end")
13853  SAvertminEntry.insert(0, "1uV")
13854  SAvertmin = 1.0E-6
13855  if ShowC1_VdB.get() == 1 or ShowMathSA.get() > 0:
13856  TRACEsize = len(FFTresultA) # Set the trace length
13857  elif ShowC2_VdB.get() == 1 or ShowMathSA.get() > 0:
13858  TRACEsize = len(FFTresultB)
13859  elif ShowAWGASA.get() > 0:
13860  TRACEsize = len(FFTresultAWGA)
13861  elif ShowAWGBSA.get() > 0:
13862  TRACEsize = len(FFTresultAWGB)
13863  #print(TRACEsize)
13864  if TRACEsize == 0: # If no trace, skip rest of this routine
13865  return()
13866  if FSweepMode.get() > 0 and LoopNum.get() == NSteps.get():
13867  PhaseA = PhaseMemoryA
13868  PhaseB = PhaseMemoryB
13869  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
13870  # Vertical conversion factors (level dBs) and border limits
13871  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
13872  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
13873  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
13874  YVc = float(Y0TF) + YVconv * SAvertmax
13875  Ymin = Y0TF # Minimum position of screen grid (top)
13876  Ymax = Y0TF + GRHF # Maximum position of screen grid (bottom)
13877  Yphconv = float(GRHF) / 360
13878  Yp = float(Y0TF) + Yphconv + 180
13879  # Horizontal conversion factors (frequency Hz) and border limits
13880  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
13881  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1) # Frequency step per sample
13882  LogFStop = math.log10(StopFrequency)
13883  try:
13884  LogFStart = math.log10(StartFrequency)
13885  except:
13886  LogFStart = 0.0
13887  LogFpixel = (LogFStop - LogFStart) / GRWF
13888  #
13889  try:
13890  LogVStop = math.log10(SAvertmax)
13891  except:
13892  LogVStop = 0.0
13893  try:
13894  LogVStart = math.log10(SAvertmin)
13895  except:
13896  LogVStart = -10
13897  LogVpixel = (LogVStop - LogVStart) / GRHF
13898  #
13899  STARTsample = StartFrequency / Fsample # First sample in FFTresult[] that is used
13900  STARTsample = int(math.ceil(STARTsample)) # First within screen range
13901 
13902  STOPsample = StopFrequency / Fsample # Last sample in FFTresult[] that is used
13903  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
13904 
13905  MAXsample = TRACEsize # Just an out of range check
13906  if STARTsample > (MAXsample - 1):
13907  STARTsample = MAXsample - 1
13908 
13909  if STOPsample > MAXsample:
13910  STOPsample = MAXsample
13911 
13912  T1Fline = []
13913  T2Fline = []
13914  TAFline = []
13915  TBFline = []
13916  T1Pline = []
13917  T2Pline = []
13918  TFMline = []
13919  n = STARTsample
13920  PeakIndexA = PeakIndexB = n
13921  PeakdbA = PeakdbB = PeakMdb = -200 # PeakdbB
13922  while n <= STOPsample:
13923  F = n * Fsample
13924  if HScale.get() == 1:
13925  try:
13926  LogF = math.log10(F) # convet to log Freq
13927  x = X0LF + (LogF - LogFStart)/LogFpixel
13928  except:
13929  x = X0LF
13930  else:
13931  x = X0LF + (F - StartFrequency) / Fpixel
13932  if ShowC1_VdB.get() == 1:
13933  T1Fline.append(int(x + 0.5))
13934  try:
13935  if SAVScale.get() == 0:
13936  if SAVPSD.get() == 1:
13937  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth))
13938  else:
13939  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
13940  ya = Yc - Yconv * dbA
13941  else:
13942  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
13943  V = 10.0**(dbA/20.0)# convert back to RMS Volts
13944  if SAVPSD.get() == 1:
13945  V = V/math.sqrt(FBinWidth) # per root Hz
13946  if SAVScale.get() == 2:
13947  try:
13948  LogV = math.log10(V) # convet to log Volts
13949  ya = YVc - (LogV - LogVStart)/LogVpixel
13950  except:
13951  ya = YVc - YVconv * V
13952  else:
13953  ya = YVc - YVconv * V
13954  except:
13955  ya = Ymax
13956  if (ya < Ymin):
13957  ya = Ymin
13958  if (ya > Ymax):
13959  ya = Ymax
13960  if dbA > PeakdbA:
13961  PeakdbA = dbA
13962  PeakyA = int(ya + 0.5)
13963  PeakxA = int(x + 0.5)
13964  PeakfreqA = F
13965  PeakIndexA = n
13966  T1Fline.append(int(ya + 0.5))
13967  if ShowC2_VdB.get() == 1:
13968  T2Fline.append(int(x + 0.5))
13969  try:
13970  if SAVScale.get() == 0:
13971  if SAVPSD.get() == 1:
13972  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
13973  else:
13974  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
13975  yb = Yc - Yconv * dbB
13976  else:
13977  dbB = 10 * math.log10(float(FFTresultB[n])) # Convert power to DBs
13978  V = 10.0**(dbB/20.0)# RMS Volts
13979  if SAVPSD.get() == 1:
13980  V = V/math.sqrt(FBinWidth) # per root Hz
13981  if SAVScale.get() == 2:
13982  try:
13983  LogV = math.log10(V) # convet to log Volts
13984  yb = YVc - (LogV - LogVStart)/LogVpixel
13985  except:
13986  yb = YVc - YVconv * V
13987  else:
13988  yb = YVc - YVconv * V
13989  except:
13990  yb = Ymax
13991  if (yb < Ymin):
13992  yb = Ymin
13993  if (yb > Ymax):
13994  yb = Ymax
13995  if dbB > PeakdbB:
13996  PeakdbB = dbB
13997  PeakyB = int(yb + 0.5)
13998  PeakxB = int(x + 0.5)
13999  PeakfreqB = F
14000  PeakIndexB = n
14001  T2Fline.append(int(yb + 0.5))
14002  if ShowAWGASA.get() > 0:
14003  TAFline.append(int(x + 0.5))
14004  try:
14005  if SAVPSD.get() == 1:
14006  dbA = 10 * math.log10(float(FFTresultAWGA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14007  else:
14008  dbA = 10 * math.log10(float(FFTresultAWGA[n])) # Convert power to DBs
14009  ya = Yc - Yconv * dbA
14010  except:
14011  ya = Ymax
14012  if (ya < Ymin):
14013  ya = Ymin
14014  if (ya > Ymax):
14015  ya = Ymax
14016  TAFline.append(int(ya + 0.5))
14017  if ShowAWGBSA.get() > 0:
14018  TBFline.append(int(x + 0.5))
14019  try:
14020  if SAVPSD.get() == 1:
14021  dbA = 10 * math.log10(float(FFTresultAWGB[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14022  else:
14023  dbA = 10 * math.log10(float(FFTresultAWGb[n])) # Convert power to DBs
14024  ya = Yc - Yconv * dbA
14025  except:
14026  ya = Ymax
14027  if (ya < Ymin):
14028  ya = Ymin
14029  if (ya > Ymax):
14030  ya = Ymax
14031  TBFline.append(int(ya + 0.5))
14032  if ShowC1_P.get() == 1:
14033  T1Pline.append(int(x + 0.5))
14034  if FSweepMode.get() > 0:
14035  RelPhase = PhaseMemoryA[n]-PhaseMemoryB[n]
14036  else:
14037  RelPhase = PhaseA[n]-PhaseB[n]
14038  RelPhase = RelPhase - Phasecenter
14039  if RelPhase > 180:
14040  RelPhase = RelPhase - 360
14041  elif RelPhase < -180:
14042  RelPhase = RelPhase + 360
14043  if Two_X_Sample.get() == 0:
14044  PhErr = 0.0018 * n * Fsample # calculate phase error due half sample period offset
14045  RelPhase = RelPhase + PhErr - 12.0
14046  else:
14047  RelPhase = RelPhase - 9.0
14048  ya = Yp - Yphconv * RelPhase
14049  T1Pline.append(int(ya + 0.5))
14050  if ShowC2_P.get() == 1:
14051  T2Pline.append(int(x + 0.5))
14052  if FSweepMode.get() > 0:
14053  RelPhase = PhaseMemoryB[n]-PhaseMemoryA[n]
14054  else:
14055  RelPhase = PhaseB[n]-PhaseA[n]
14056  RelPhase = RelPhase - Phasecenter
14057  if RelPhase > 180:
14058  RelPhase = RelPhase - 360
14059  elif RelPhase < -180:
14060  RelPhase = RelPhase + 360
14061  if Two_X_Sample.get() == 0:
14062  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14063  RelPhase = RelPhase - PhErr - 12.0
14064  else:
14065  RelPhase = RelPhase - 9.0
14066  ya = Yp - Yphconv * RelPhase
14067  T2Pline.append(int(ya + 0.5))
14068  if ShowMathSA.get() > 0:
14069  TFMline.append(int(x + 0.5))
14070  if SAVPSD.get() == 1:
14071  dbA = 10 * math.log10(float(FFTresultA[n])/math.sqrt(FBinWidth)) # Convert power to DBs
14072  dbB = 10 * math.log10(float(FFTresultB[n])/math.sqrt(FBinWidth))
14073  else:
14074  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs
14075  dbB = 10 * math.log10(float(FFTresultB[n]))
14076  if ShowMathSA.get() == 1:
14077  MdB = dbA - dbB
14078  elif ShowMathSA.get() == 2:
14079  MdB = dbB - dbA
14080  yb = Yc - Yconv * MdB
14081  if (yb < Ymin):
14082  yb = Ymin
14083  if (yb > Ymax):
14084  yb = Ymax
14085  if MdB > PeakMdb:
14086  PeakMdb = MdB
14087  PeakyM = int(yb + 0.5)
14088  PeakxM = int(x + 0.5)
14089  PeakfreqM = F
14090  TFMline.append(int(yb + 0.5))
14091  n = n + 1
14092 #
14093 # make Bode Plot Traces
14094 def MakeBodeTrace(): # Update the grid and trace
14095  global FSweepAdB, FSweepBdB, FSweepAPh, FSweepBPh, FStep, FBins
14096  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMathBP
14097  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14098  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14099  global PeakfreqA, PeakfreqB, Two_X_Sample, PhaseOffset1x, PhaseOffset2x
14100  global DBdivindexBP # Index value
14101  global DBdivlist # dB per division list
14102  global DBlevelBP # Reference level
14103  global GRHBP # Screenheight
14104  global GRWBP # Screenwidth
14105  global AWGSAMPLErate, HScaleBP, RUNstatus, SAMPLErate, BaseSampleRate
14106  global StartBodeEntry, StopBodeEntry, SMPfft
14107  global STARTsample, STOPsample, LoopNum, FSweepMode
14108  global FreqTraceMode, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14109  global TAFline, TBFline, TBPMline, TAPline, TBPline
14110  global Vdiv # Number of vertical divisions
14111  global X0LBP # Left top X value
14112  global Y0TBP # Left top Y value
14113  global ResScale, NetworkScreenStatus, Show_Rseries, NSweepSeriesR, Show_Xseries, NSweepSeriesX
14114  global Show_Magnitude, NSweepSeriesMag, Show_Angle, NSweepSeriesAng
14115  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14116 
14117  # Set the TRACEsize variable
14118  TRACEsize = 0
14119  if ShowCA_VdB.get() == 1 or ShowMathBP.get() > 0:
14120  TRACEsize = len(FStep) # Set the trace length
14121  elif ShowCB_VdB.get() == 1 or ShowMathBP.get() > 0:
14122  TRACEsize = len(FStep)
14123  if TRACEsize == 0: # If no trace, skip rest of this routine
14124  return()
14125  #
14126  try:
14127  EndFreq = float(StopBodeEntry.get())
14128  except:
14129  StopBodeEntry.delete(0,"end")
14130  StopBodeEntry.insert(0,10000)
14131  EndFreq = 10000
14132  try:
14133  BeginFreq = float(StartBodeEntry.get())
14134  except:
14135  StartBodeEntry.delete(0,"end")
14136  StartBodeEntry.insert(0,100)
14137  BeginFreq = 100
14138  try:
14139  Phasecenter = int(PhCenBodeEntry.get())
14140  RelPhaseCenter.set(Phasecenter)
14141  except:
14142  PhCenBodeEntry.delete(0,"end")
14143  PhCenBodeEntry.insert(0,0)
14144  RelPhaseCenter.set(0)
14145  Phasecenter = 0
14146  try:
14147  Impedcenter = int(ImCenBodeEntry.get())
14148  ImpedanceCenter.set(Impedcenter)
14149  except:
14150  ImCenBodeEntry.delete(0,"end")
14151  ImCenBodeEntry.insert(0,0)
14152  ImpedanceCenter.set(0)
14153  Impedcenter = 0
14154  #
14155  HalfSAMPLErate = SAMPLErate/2
14156  BeginIndex = int((BeginFreq/HalfSAMPLErate)*16384)
14157  EndIndex = int((EndFreq/HalfSAMPLErate)*16384)
14158  CurrentFreqX = X0LBP + 14
14159  if FSweepMode.get() > 0 and len(FSweepAdB) > 4:
14160  # Vertical conversion factors (level dBs) and border limits
14161  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14162  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14163  Ymin = Y0TBP # Minimum position of screen grid (top)
14164  Ymax = Y0TBP + GRHBP # Maximum position of screen grid (bottom)
14165  Yphconv = float(GRHBP) / 360 # degrees per pixel
14166  Yp = float(Y0TBP) + Yphconv + 180
14167  x1 = X0LBP + 14
14168  # Horizontal conversion factors (frequency Hz) and border limits
14169  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14170  LogFStop = math.log10(EndFreq)
14171  try:
14172  LogFStart = math.log10(BeginFreq)
14173  except:
14174  LogFStart = 0.0
14175  LogFpixel = (LogFStop - LogFStart) / GRWBP
14176  TAFline = []
14177  TBFline = []
14178  TAPline = []
14179  TBPline = []
14180  TIARline = []
14181  TIAXline = []
14182  TIAMagline = []
14183  TIAAngline = []
14184  TBPMline = []
14185  PeakdbA = -200
14186  PeakdbB = -200
14187  PeakMdb = -200
14188  n = 0
14189  for n in range(len(FSweepAdB)): # while n < len(FStep):
14190  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
14191  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
14192  else:
14193  F = FBins[int(FStep[0])]
14194  if F >= BeginFreq and F <= EndFreq:
14195  if HScaleBP.get() == 1:
14196  try:
14197  LogF = math.log10(F) # convet to log Freq
14198  x = x1 + (LogF - LogFStart)/LogFpixel
14199  except:
14200  x = x1
14201  else:
14202  x = x1 + (F - BeginFreq) / Fpixel
14203  CurrentFreqX = x
14204  if ShowCA_VdB.get() == 1:
14205  TAFline.append(int(x + 0.5))
14206  try:
14207  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
14208  ya = Yc - Yconv * dbA
14209  except:
14210  ya = Ymax
14211  if (ya < Ymin):
14212  ya = Ymin
14213  if (ya > Ymax):
14214  ya = Ymax
14215  if dbA > PeakdbA:
14216  PeakdbA = dbA
14217  PeakyA = int(ya + 0.5)
14218  PeakxA = int(x + 0.5)
14219  PeakfreqA = F
14220  TAFline.append(int(ya + 0.5))
14221  if ShowCB_VdB.get() == 1:
14222  TBFline.append(int(x + 0.5))
14223  try:
14224  dbB = 10 * math.log10(float(FSweepBdB[n]))
14225  yb = Yc - Yconv * dbB
14226  except:
14227  yb = Ymax
14228  if (yb < Ymin):
14229  yb = Ymin
14230  if (yb > Ymax):
14231  yb = Ymax
14232  if dbB > PeakdbB:
14233  PeakdbB = dbB
14234  PeakyB = int(yb + 0.5)
14235  PeakxB = int(x + 0.5)
14236  PeakfreqB = F
14237  TBFline.append(int(yb + 0.5))
14238  if ShowCA_P.get() == 1:
14239  TAPline.append(int(x + 0.5))
14240  RelPhase = FSweepAPh[n] - FSweepBPh[n]
14241  RelPhase = RelPhase - Phasecenter
14242  if RelPhase > 180:
14243  RelPhase = RelPhase - 360
14244  elif RelPhase < -180:
14245  RelPhase = RelPhase + 360
14246  if Two_X_Sample.get() == 0:
14247  PhErr = 0.0018 * F # calculate phase error due half sample period offset
14248  RelPhase = RelPhase + PhErr - PhaseOffset1x
14249  else:
14250  RelPhase = RelPhase - PhaseOffset2x
14251  ya = Yp - Yphconv * RelPhase
14252  TAPline.append(int(ya + 0.5))
14253  if ShowCB_P.get() == 1:
14254  TBPline.append(int(x + 0.5))
14255  RelPhase = FSweepBPh[n] - FSweepAPh[n]
14256  RelPhase = RelPhase - Phasecenter
14257  if RelPhase > 180:
14258  RelPhase = RelPhase - 360
14259  elif RelPhase < -180:
14260  RelPhase = RelPhase + 360
14261  if Two_X_Sample.get() == 0:
14262  PhErr = 0.0018 * F # calculate phase error due half sample period offset
14263  RelPhase = RelPhase - PhErr - PhaseOffset1x
14264  else:
14265  RelPhase = RelPhase - PhaseOffset2x
14266  ya = Yp - Yphconv * RelPhase
14267  TBPline.append(int(ya + 0.5))
14268  if ShowMathBP.get() > 0:
14269  TBPMline.append(int(x + 0.5))
14270  dbA = 10 * math.log10(float(FSweepAdB[n])) # Convert power to DBs, except for log(0) error
14271  dbB = 10 * math.log10(float(FSweepBdB[n]))
14272  if ShowMathBP.get() == 1:
14273  MdB = dbA - dbB
14274  elif ShowMathBP.get() == 2:
14275  MdB = dbB - dbA
14276  yb = Yc - Yconv * MdB
14277  if (yb < Ymin):
14278  yb = Ymin
14279  if (yb > Ymax):
14280  yb = Ymax
14281  if MdB > PeakMdb:
14282  PeakMdb = MdB
14283  PeakyM = int(yb + 0.5)
14284  PeakxM = int(x + 0.5)
14285  PeakfreqM = F
14286  TBPMline.append(int(yb + 0.5))
14287 # draw impedance trace if necessary
14288  if NetworkScreenStatus.get() > 0:
14289  ycenter = Y0TBP + (GRHBP/2)
14290  OhmsperPixel = float(ResScale.get())*Vdiv.get()/GRHBP
14291  n = 0
14292  for n in range(len(NSweepSeriesR)): # while n < len(FStep):
14293  if n < len(FStep): # check if n has gone out off bounds because user did something dumb
14294  F = FBins[int(FStep[n])] # look up frequency bin in list of bins
14295  else:
14296  F = FBins[int(FStep[0])]
14297  if F >= BeginFreq and F <= EndFreq:
14298  if HScaleBP.get() == 1:
14299  try:
14300  LogF = math.log10(F) # convet to log Freq
14301  x = x1 + (LogF - LogFStart)/LogFpixel
14302  except:
14303  x = x1
14304  else:
14305  x = x1 + (F - BeginFreq) / Fpixel
14306  if Show_Rseries.get() == 1:
14307  TIARline.append(int(x + 0.5))
14308  y1 = ycenter - ((NSweepSeriesR[n]-Impedcenter) / OhmsperPixel)
14309  if (y1 < Ymin):
14310  y1 = Ymin
14311  if (y1 > Ymax):
14312  y1 = Ymax
14313  TIARline.append(y1)
14314  if Show_Xseries.get() == 1:
14315  TIAXline.append(int(x + 0.5))
14316  y1 = ycenter - ((NSweepSeriesX[n]-Impedcenter) / OhmsperPixel)
14317  if (y1 < Ymin):
14318  y1 = Ymin
14319  if (y1 > Ymax):
14320  y1 = Ymax
14321  TIAXline.append(y1)
14322  if Show_Magnitude.get() == 1:
14323  TIAMagline.append(int(x + 0.5))
14324  y1 = ycenter - ((NSweepSeriesMag[n]-Impedcenter) / OhmsperPixel)
14325  if (y1 < Ymin):
14326  y1 = Ymin
14327  if (y1 > Ymax):
14328  y1 = Ymax
14329  TIAMagline.append(y1)
14330  if Show_Angle.get() == 1:
14331  TIAAngline.append(int(x + 0.5))
14332  y1 = ycenter - Yphconv * (NSweepSeriesAng[n]-Phasecenter)
14333  if (y1 < Ymin):
14334  y1 = Ymin
14335  if (y1 > Ymax):
14336  y1 = Ymax
14337  TIAAngline.append(y1)
14338 #
14339 def MakeBodeScreen(): # Update the screen with traces and text
14340  global CANVASheightBP, CANVASwidthBP, SmoothCurvesBP
14341  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14342  global PeakxM, PeakyM, PeakMdb, PeakfreqM
14343  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
14344  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
14345  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
14346  global COLORgrid # The colors
14347  global COLORsignalband, COLORtext
14348  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
14349  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
14350  global DBdivindexBP # Index value
14351  global DBdivlist # dB per division list
14352  global DBlevelBP # Reference level
14353  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
14354  global X0LBP # Left top X value
14355  global Y0TBP # Left top Y value
14356  global GRWBP # Screenwidth
14357  global GRHBP # Screenheight
14358  global FontSize
14359  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
14360  global AWGSAMPLErate, HScaleBP, SAMPLErate, BaseSampleRate
14361  global SMPfft # number of FFT samples
14362  global StartBodeEntry, StopBodeEntry
14363  global ShowCA_P, ShowCB_P, ShowRA_VdB, ShowRB_VdB, ShowMarkerBP
14364  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP
14365  global ShowMathBP, BodeDisp, RelPhaseCenter, PhCenBodeEntry, ImCenBodeEntry, ImpedanceCenter, Impedcenter
14366  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
14367  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, NetworkScreenStatus
14368  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
14369  global TAFline, TBFline, TAPline, TAFRline, TBFRline, TBPMline, TBPRMline
14370  global TAPRline, TBPRline
14371  global TRACEaverage # Number of traces for averageing
14372  global FreqTraceMode # 1 normal 2 max 3 average
14373  global Vdiv, ResScale # Number of vertical divisions
14374  global TIARline, TIAXline, TIAMagline, TIAAngline, CurrentFreqX
14375  global RefIARline, RefIAXline, RefIAMagline, RefIAAngline
14376 
14377  # Delete all items on the screen
14378  MarkerFreqNum = 0
14379  Bodeca.delete(ALL) # remove all items
14380 
14381  try:
14382  EndFreq = float(StopBodeEntry.get())
14383  except:
14384  StopBodeEntry.delete(0,"end")
14385  StopBodeEntry.insert(0,10000)
14386  EndFreq = 10000
14387  try:
14388  BeginFreq = float(StartBodeEntry.get())
14389  except:
14390  StartBodeEntry.delete(0,"end")
14391  StartBodeEntry.insert(0,100)
14392  BeginFreq = 100
14393  try:
14394  Phasecenter = int(PhCenBodeEntry.get())
14395  RelPhaseCenter.set(Phasecenter)
14396  except:
14397  PhCenBodeEntry.delete(0,"end")
14398  PhCenBodeEntry.insert(0,0)
14399  RelPhaseCenter.set(0)
14400  Phasecenter = 0
14401  try:
14402  Impedcenter = int(ImCenBodeEntry.get())
14403  ImpedanceCenter.set(Impedcenter)
14404  except:
14405  ImCenBodeEntry.delete(0,"end")
14406  ImCenBodeEntry.insert(0,0)
14407  ImpedanceCenter.set(0)
14408  Impedcenter = 0
14409  #
14410  # Draw horizontal grid lines
14411  i = 0
14412  x1 = X0LBP + 14
14413  x2 = x1 + GRWBP
14414  while (i <= Vdiv.get()):
14415  y = Y0TBP + i * GRHBP/Vdiv.get()
14416  Dline = [x1,y,x2,y]
14417  if i == 0 or i == Vdiv.get():
14418  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14419  else:
14420  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14421  Vaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
14422  Vaxis_label = str(Vaxis_value)
14423  Bodeca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
14424  if ShowCA_P.get() == 1 or ShowCB_P.get() == 1 or Show_Angle.get() == 1:
14425  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get()))) + Phasecenter
14426  Vaxis_label = str(Vaxis_value)
14427  Bodeca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
14428  if NetworkScreenStatus.get() > 0:
14429  if Show_Rseries.get() == 1 or Show_Xseries.get() == 1 or Show_Magnitude.get() == 1:
14430  RperDiv = float(ResScale.get())
14431  Vaxis_value = ( (RperDiv * Vdiv.get()/2) - (i * RperDiv) ) + Impedcenter
14432  if Vaxis_value > 500 or Vaxis_value < -500:
14433  Vaxis_value = Vaxis_value/1000.0
14434  if Vaxis_value > 5 or Vaxis_value < -5:
14435  Vaxis_label = ' {0:.0f}'.format(Vaxis_value) + 'K'
14436  else:
14437  Vaxis_label = ' {0:.1f}'.format(Vaxis_value) + 'K'
14438  else:
14439  Vaxis_label = ' {0:.0f} '.format(Vaxis_value)
14440  Bodeca.create_text(x1-23, y, text=Vaxis_label, fill=COLORtrace5, anchor="e", font=("arial", FontSize ))
14441  i = i + 1
14442  # Draw vertical grid lines
14443  i = 0
14444  y1 = Y0TBP
14445  y2 = Y0TBP + GRHBP
14446  if HScaleBP.get() == 1:
14447  F = 1.0
14448  LogFStop = math.log10(EndFreq)
14449  try:
14450  LogFStart = math.log10(BeginFreq)
14451  except:
14452  LogFStart = 0.0
14453  LogFpixel = (LogFStop - LogFStart) / GRWBP
14454  # draw left and right edges
14455  while F <= EndFreq:
14456  if F >= BeginFreq:
14457  try:
14458  LogF = math.log10(F) # convet to log Freq
14459  x = x1 + (LogF - LogFStart)/LogFpixel
14460  except:
14461  x = x1
14462  Dline = [x,y1,x,y2]
14463  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
14464  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14465  axis_label = str(F)
14466  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
14467  else:
14468  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14469 
14470  if F < 10:
14471  F = F + 1
14472  elif F < 100:
14473  F = F + 10
14474  elif F < 1000:
14475  F = F + 100
14476  elif F < 1000:
14477  F = F + 100
14478  elif F < 10000:
14479  F = F + 1000
14480  elif F < 100000:
14481  F = F + 10000
14482  elif F < 200000:
14483  F = F + 10000
14484  else:
14485  Freqdiv = (EndFreq - BeginFreq) / 10
14486  while (i < 11):
14487  x = x1 + i * GRWBP/10
14488  Dline = [x,y1,x,y2]
14489  if i == 0 or i == 10:
14490  Bodeca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14491  else:
14492  Bodeca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14493  axis_value = BeginFreq + (i * Freqdiv)
14494  axis_label = str(axis_value)
14495  Bodeca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
14496  i = i + 1
14497  # Draw X - Y cursors if needed
14498  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
14499  LogFStop = math.log10(EndFreq)
14500  try:
14501  LogFStart = math.log10(BeginFreq)
14502  except:
14503  LogFStart = 0.0
14504  LogFpixel = (LogFStop - LogFStart) / GRWBP
14505  if ShowBPCur.get() > 0:
14506  Dline = [BPCursor, Y0TBP, BPCursor, Y0TBP+GRHBP]
14507  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
14508  # Horizontal conversion factors (frequency Hz) and border limits
14509  if HScaleBP.get() == 1:
14510  xfreq = 10**(((BPCursor-x1)*LogFpixel) + LogFStart)
14511  else:
14512  xfreq = ((BPCursor-x1)*Fpixel)+BeginFreq
14513  XFString = ' {0:.2f} '.format(xfreq)
14514  V_label = XFString + " Hz"
14515  Bodeca.create_text(BPCursor, Y0TBP+GRHBP+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
14516  #Bodeca.create_text(BPCursor+1, BdBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14517 #
14518  if ShowBdBCur.get() > 0:
14519  Dline = [x1, BdBCursor, x1+GRWBP, BdBCursor]
14520  Bodeca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
14521  if ShowBdBCur.get() == 1:
14522  # Vertical conversion factors (level dBs) and border limits
14523  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
14524  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
14525  yvdB = ((Yc-BdBCursor)/Yconv)
14526  VdBString = ' {0:.1f} '.format(yvdB)
14527  V_label = VdBString + " dBV"
14528  else:
14529  # Vertical conversion factors (level degrees) and border limits
14530  Yconv = float(GRHBP) / 360.0 # Conversion factors, Yconv is the number of screenpoints per degree
14531  Yc = float(Y0TBP) # Yc is the 180 degree position
14532  yvdB = 180 + ((Yc-BdBCursor)/Yconv) + Phasecenter
14533  VdBString = ' {0:.1f} '.format(yvdB)
14534  V_label = VdBString + " Deg"
14535  Bodeca.create_text(x1+GRWBP+1, BdBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14536  #Bodeca.create_text(BPCursor+1, BdBCursor+5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
14537  #
14538  SmoothBool = SmoothCurvesBP.get()
14539  # Draw traces
14540  if len(TAFline) > 4: # Avoid writing lines with 1 coordinate
14541  # Write the trace CHA
14542  if OverRangeFlagA == 1:
14543  Bodeca.create_line(TAFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14544  else:
14545  Bodeca.create_line(TAFline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14546  if ShowMarkerBP.get() == 1:
14547  Peak_label = ' {0:.2f} '.format(PeakdbA) + ',' + ' {0:.1f} '.format(PeakfreqA)
14548  Bodeca.create_text(PeakxA, PeakyA, text=Peak_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
14549  if len(TBFline) > 4: # Avoid writing lines with 1 coordinate
14550  # Write the trace CHB
14551  if OverRangeFlagB == 1:
14552  Bodeca.create_line(TBFline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14553  else:
14554  Bodeca.create_line(TBFline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14555  if ShowMarkerBP.get() == 1:
14556  Peak_label = ' {0:.2f} '.format(PeakdbB) + ',' + ' {0:.1f} '.format(PeakfreqB)
14557  Bodeca.create_text(PeakxB, PeakyB, text=Peak_label, fill=COLORtrace2, anchor="w", font=("arial", FontSize ))
14558  if len(TAPline) > 4: # Avoid writing lines with 1 coordinate
14559  # Write the phase trace A-B
14560  Bodeca.create_line(TAPline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14561  if len(TBPline) > 4: # Avoid writing lines with 1 coordinate
14562  # Write the phase trace A-B
14563  Bodeca.create_line(TBPline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14564  if ShowCA_RdB.get() == 1 and len(TAFRline) > 4: # Write the ref trace A if active
14565  Bodeca.create_line(TAFRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14566  if ShowMarkerBP.get() == 1:
14567  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
14568  Bodeca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="e", font=("arial", FontSize ))
14569  if ShowCB_RdB.get() == 1 and len(TBFRline) > 4: # Write the ref trace B if active
14570  Bodeca.create_line(TBFRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14571  if ShowMarkerBP.get() == 1:
14572  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
14573  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="w", font=("arial", FontSize ))
14574  if ShowCA_RP.get() == 1 and len(TAPRline) > 4: # Write the ref trace A if active
14575  Bodeca.create_line(TAPRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14576  if ShowCB_RP.get() == 1 and len(TBPRline) > 4: # Write the ref trace A if active
14577  Bodeca.create_line(TBPRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14578  if ShowMathBP.get() > 0 and len(TBPMline) > 4: # Write the Math trace if active
14579  Bodeca.create_line(TBPMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14580  if ShowMarkerBP.get() == 1:
14581  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
14582  Bodeca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="w", font=("arial", FontSize ))
14583  if ShowRMathBP.get() == 1 and len(TBPRMline) > 4: # Write the ref math trace if active
14584  Bodeca.create_line(TBPRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14585  if ShowMarkerBP.get() == 1:
14586  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
14587  Bodeca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="w", font=("arial", FontSize ))
14588  if Show_Rseries.get() == 1 and len(TIARline) > 4:
14589  Bodeca.create_line(TIARline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14590  if Show_Xseries.get() == 1 and len(TIAXline) > 4:
14591  Bodeca.create_line(TIAXline, fill=COLORtrace6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14592  if Show_Magnitude.get() == 1 and len(TIAMagline) > 4:
14593  Bodeca.create_line(TIAMagline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14594  if Show_Angle.get() == 1 and len(TIAAngline) > 4:
14595  Bodeca.create_line(TIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14596  if Show_RseriesRef.get() == 1 and len(RefIARline) > 4:
14597  Bodeca.create_line(RefIARline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14598  if Show_XseriesRef.get() == 1 and len(RefIAXline) > 4:
14599  Bodeca.create_line(RefIAXline, fill=COLORtraceR6, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14600  if Show_MagnitudeRef.get() == 1 and len(RefIAMagline) > 4:
14601  Bodeca.create_line(RefIAMagline, fill=COLORtraceR7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14602  if Show_AngleRef.get() == 1 and len(RefIAAngline) > 4:
14603  Bodeca.create_line(RefIAAngline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14604 
14605  Dline = [CurrentFreqX, Y0TBP, CurrentFreqX, Y0TBP+GRHBP]
14606  Bodeca.create_line(Dline, dash=(2,2), fill=COLORgrid, width=GridWidth.get())
14607  if HScaleBP.get() == 1:
14608  xfreq = 10**(((CurrentFreqX-x1)*LogFpixel) + LogFStart)
14609  else:
14610  xfreq = ((CurrentFreqX-x1)*Fpixel)+BeginFreq
14611  XFString = ' {0:.0f} '.format(xfreq)
14612  V_label = XFString + " Hz"
14613  Bodeca.create_text(CurrentFreqX, Y0TBP+GRHBP+1, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
14614  # General information on top of the grid
14615 
14616  txt = " Sample rate: " + str(SAMPLErate)
14617  txt = txt + " FFT samples: " + str(SMPfft)
14618 
14619  txt = txt + " " + FFTwindowname
14620 
14621  x = X0LBP
14622  y = 12
14623  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14624 
14625  # Start and stop frequency and dB/div and trace mode
14626  txt = str(BeginFreq) + " to " + str(EndFreq) + " Hz"
14627  txt = txt + " " + str(DBdivlist[DBdivindexBP.get()]) + " dB/div"
14628  txt = txt + " Level: " + str(DBlevelBP.get()) + " dB "
14629  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
14630 
14631  x = X0LBP
14632  y = Y0TBP+GRHBP+23
14633  idTXT = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14634 
14635  if FreqTraceMode.get() == 1:
14636  txt ="Normal mode "
14637 
14638  if FreqTraceMode.get() == 2:
14639  txt = "Peak hold mode "
14640 
14641  if FreqTraceMode.get() == 3:
14642  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
14643 
14644  if ZEROstuffing.get() > 0:
14645  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
14646  # Runstatus and level information
14647  if (RUNstatus.get() == 0):
14648  txt = txt + " Stopped "
14649  else:
14650  if BodeDisp.get() == 1:
14651  txt = txt + " Running "
14652  else:
14653  txt = txt + " Display off "
14654  if FSweepMode.get() > 0:
14655  txt = txt + " Freq Step = " + str(LoopNum.get())
14656  x = X0LBP
14657  y = Y0TBP+GRHBP+34
14658  IDtxt = Bodeca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
14659 
14660 # Impedance analyzer routines -----
14661 def UpdateIAAll(): # Update Data, trace and screen
14662  global FFTBuffA, FFTBuffB
14663  global SMPfft
14664 
14665  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
14666  return
14667 
14668  MakeIATrace() # Update the traces
14669  UpdateIAScreen() # Update the screen
14670 
14671 def UpdateIATrace(): # Update trace and screen
14672  MakeIATrace() # Update traces
14673  UpdateIAScreen() # Update the screen
14674 
14675 def UpdateIAScreen(): # Update screen with trace and text
14676  MakeIAScreen() # Update the screen
14677  root.update() # Activate updated screens
14678 #
14680 
14681 # Input Variables
14682  global PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
14683  #(VZ/VA)from vector voltmeter
14684  # global VVangle # angle in degrees between VZ and VA
14685  global RsystemEntry # resistance of series resistor or power divider
14686 # Computed outputs
14687  # global VVangleCosine # cosine of vector voltmeter angle
14688  global ImpedanceMagnitude # in ohms
14689  global ImpedanceAngle # in degrees
14690  global ImpedanceRseries, ImpedanceXseries # in ohms
14691  global IA_Ext_Conf
14692 
14693  DEG2RAD = (math.pi / 180.0)
14694  SMALL = 1E-20
14695  try:
14696  ResValue = float(RsystemEntry.get())
14697  except:
14698  ResValue = 1000.0
14699 
14700  VA = math.pow(10,(PeakdbA/20))
14701  VB = math.pow(10,(PeakdbB/20))
14702  VVangleCosine = math.cos(math.radians(PeakRelPhase))
14703  if IA_Ext_Conf.get() == 1:
14704  VAB = math.pow(10,(PeakdbAB/20))
14705  VZ = VAB # VZ=VA-VB
14706  # VI = VB
14707  else:
14708  VZ = VB # VZ=VB
14709  VI = math.sqrt(VA**2 + VZ**2 - 2*VA*VZ*VVangleCosine)
14710  costheta = (VA**2 + VI**2 - VZ**2)/(2 * VA * VI)
14711  Za = ResValue * VA / VI
14712  ImpedanceRseries = Za * costheta - ResValue
14713  ImpedanceMagnitude = ResValue * VZ / VI
14714  # don't try to take square root of a negative number)
14715  ImpedanceXseries = math.sqrt(abs(ImpedanceMagnitude**2 - ImpedanceRseries**2))
14716 
14717  if(PeakRelPhase < 0.0):
14718  ImpedanceXseries = -ImpedanceXseries
14719  if IA_Ext_Conf.get() == 1:
14720  ImpedanceRseries = -ImpedanceRseries
14721  ImpedanceAngle = math.atan2(ImpedanceXseries, ImpedanceRseries) / DEG2RAD
14722 #
14723 def MakeIATrace(): # Update the grid and trace
14724  global FFTmemoryA, FFTresultA, FFTresultAB, PhaseAB
14725  global FFTmemoryB, FFTresultB
14726  global PhaseA, PhaseB, PhaseMemoryA, PhaseMemoryB
14727  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB, PeakRelPhase, PeakdbAB
14728  global PeakxM, PeakyM, PeakMdb, PeakfreqM, PeakphaseA, PeakphaseB
14729  global PeakfreqA, PeakfreqB, GainCorEntry, PhaseCorEntry, PhaseCorrection
14730  global DBdivindex # Index value
14731  global DBdivlist # dB per division list
14732  global DBlevel # Reference level
14733  global GRHIA # Screenheight
14734  global GRWIA # Screenwidth
14735  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SMPfft
14736  global STARTsample, STOPsample, LoopNum, FSweepMode
14737  global TRACEmode, Two_X_Sample, IA_Ext_Conf
14738  global T1Vline, T2Vline, TMline, T1Pline, T2Pline
14739  global Vdiv # Number of vertical divisions
14740  global X0LIA # Left top X value
14741  global Y0TIA # Left top Y value
14742  global ImpedanceMagnitude # in ohms
14743  global ImpedanceAngle # in degrees
14744  global ImpedanceRseries, ImpedanceXseries # in ohms
14745 
14746  # Set the TRACEsize variable
14747  TRACEsize = len(FFTresultA) # Set the trace length
14748  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
14749  # Horizontal conversion factors (frequency Hz) and border limits
14750  STARTsample = 0 # First sample in FFTresult[] that is used
14751  STARTsample = int(math.ceil(STARTsample)) # First within screen range
14752  if Two_X_Sample.get() == 0:
14753  STOPsample = 45000 / Fsample # Last sample in FFTresult[] that is used
14754  else:
14755  STOPsample = 90000 / Fsample
14756  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
14757 #
14758  RMScorr = 1.0 / SMPfft # For VOLTAGE!
14759  Powcorr = RMScorr **2 # vpktage squared For POWER!
14760  try:
14761  GainCorrection = float(eval(GainCorEntry.get()))
14762  except:
14763  GainCorEntry.delete(0,END)
14764  GainCorEntry.insert(0, GainCorrection)
14765 
14766  try:
14767  PhaseCorrection = float(eval(PhaseCorEntry.get()))
14768  except:
14769  PhaseCorEntry.delete(0,END)
14770  PhaseCorEntry.insert(0, PhaseCorrection)
14771 
14772  MAXsample = TRACEsize # Just an out of range check
14773  if STARTsample > (MAXsample - 1):
14774  STARTsample = MAXsample - 1
14775 
14776  if STOPsample > MAXsample:
14777  STOPsample = MAXsample
14778 
14779  n = STARTsample
14780  PeakfreqA = PeakfreqB = PeakfreqM = F = n * Fsample
14781  PeakphaseA = PhaseA[n]
14782  PeakphaseB = PhaseB[n]
14783  #PeakphaseAB = PhaseAB[n]
14784  PeakSample = n
14785 
14786  PeakdbA = 10 * math.log10(float(FFTresultA[n]))
14787  PeakdbB = 10 * math.log10(float(FFTresultB[n]))
14788  PeakMdb = PeakdbA - PeakdbB
14789  if IA_Ext_Conf.get() == 1:
14790  PeakdbAB = 10 * math.log10(float(FFTresultAB[n]))
14791  while n <= STOPsample:
14792  F = n * Fsample
14793  try:
14794  dbA = 10 * math.log10(float(FFTresultA[n])) # Convert power to DBs, except for log(0) error
14795  except:
14796  dbA = -200
14797  if dbA > PeakdbA:
14798  PeakdbA = dbA
14799  PeakfreqA = F
14800  PeakphaseA = PhaseA[n]
14801  PeakSample = n
14802 
14803  try:
14804  dbB = 10 * math.log10(float(FFTresultB[n]))
14805  except:
14806  dbB = -200
14807  if dbB > PeakdbB:
14808  PeakdbB = dbB
14809  PeakfreqB = F
14810  PeakphaseB = PhaseB[n]
14811 
14812  if IA_Ext_Conf.get() == 1:
14813  try:
14814  dbAB = 10 * math.log10(float(FFTresultAB[n]))
14815  except:
14816  dbAB = -200
14817  if dbAB > PeakdbAB:
14818  PeakdbAB = dbAB
14819  PeakphaseAB = PhaseAB[n]
14820  RelPhase = PhaseA[n]-PhaseB[n]
14821  if RelPhase > 180:
14822  RelPhase = RelPhase - 360
14823  elif RelPhase < -180:
14824  RelPhase = RelPhase + 360
14825  if Two_X_Sample.get() == 0:
14826  PhErr = 0.0018 * n * Fsample # calculate pahse error due half sample period offset
14827  RelPhase = RelPhase + PhErr - 12.0
14828  else:
14829  RelPhase = RelPhase - 9.0
14830  n = n + 1
14831  if IA_Ext_Conf.get() == 1:
14832  PeakRelPhase = PeakphaseAB-PeakphaseA
14833  else:
14834  PeakRelPhase = PeakphaseB-PeakphaseA
14835 #
14836  if PeakRelPhase > 180:
14837  PeakRelPhase = PeakRelPhase - 360
14838  elif PeakRelPhase < -180:
14839  PeakRelPhase = PeakRelPhase + 360
14840  if Two_X_Sample.get() == 0:
14841  PhErr = 0.0018 * PeakSample * Fsample # calculate pahse error due half sample period offset
14842  PeakRelPhase = PeakRelPhase + PhaseCorrection - PhErr # - 12
14843  else:
14844  PeakRelPhase = PeakRelPhase + PhaseCorrection
14845  PeakdbB = PeakdbB + GainCorrection
14846  DoImpedance()
14847 
14849 def MakeIAScreen(): # Update the screen with traces and text
14850  global CANVASheightIA, CANVASwidthIA, IAca, TIAMline, TIAMRline
14851  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
14852  global PeakxM, PeakyM, PeakMdb, PeakfreqM, Two_X_Sample
14853  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
14854  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
14855  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM
14856  global PeakphaseA, PeakphaseB, PeakRelPhase, PhaseCalEntry, CapZeroEntry
14857  global SmoothCurvesBP, TRACEwidth, GridWidth # The colors
14858  global COLORsignalband, COLORtext, COLORgrid, IASweepSaved
14859  global COLORtrace1, COLORtrace2, COLORtrace5, COLORtrace6
14860  global ResScale, DisplaySeries # Ohms per div
14861  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
14862  global X0LIA # Left top X value
14863  global Y0TIA # Left top Y value
14864  global GRWIA # Screenwidth
14865  global GRHIA # Screenheight
14866  global FontSize, IAGridType
14867  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
14868  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
14869  global SMPfft # number of FFT samples
14870  global TRACEaverage # Number of traces for averageing
14871  global FreqTraceMode # 1 normal 2 max 3 average
14872  global Vdiv # Number of vertical divisions
14873  global ImpedanceMagnitude # in ohms
14874  global ImpedanceAngle # in degrees
14875  global ImpedanceRseries, ImpedanceXseries, Cseries # in ohms / uF
14876  global LoopNum, NetworkScreenStatus, NSweepSeriesR, NSweepSeriesX, NSweepSeriesMag, NSweepSeriesAng
14877  global NSweepParallelR, NSweepParallelC, NSweepParallelL, NSweepSeriesC, NSweepSeriesC
14878 
14879  # Delete all items on the screen
14880  IAca.delete(ALL) # remove all items
14881  SmoothBool = SmoothCurvesBP.get()
14882  Cparallel = 0.0
14883  Rparallel = 0.0
14884  Lparallel = 0.0
14885  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
14886  xright = 10 + GRWIA/2 + ( Vdiv.get() * Radius ) # 5
14887  OhmsperPixel = float(ResScale.get())/Radius
14888  TRadius = Radius * Vdiv.get() # 5
14889  xcenter = GRWIA/2
14890  ycenter = GRHIA/2
14891  if IAGridType.get() == 0:
14892  # Draw circular grid lines
14893  i = 1
14894  xcenter = GRWIA/2
14895  ycenter = GRHIA/2
14896  Radius = (GRWIA-X0LIA)/(1 + Vdiv.get()*2) # 11
14897  OhmsperPixel = float(ResScale.get())/Radius
14898  TRadius = Radius * Vdiv.get() # 5
14899  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
14900  while (i <= Vdiv.get()):
14901  x0 = xcenter - ( i * Radius )
14902  x1 = xcenter + ( i * Radius )
14903  y0 = ycenter - ( i * Radius )
14904  y1 = ycenter + ( i * Radius )
14905  axisvalue = float(ResScale.get()) * i
14906  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
14907  axisvalue = axisvalue / 1000
14908  ResTxt = '{0:.1f}'.format(axisvalue)
14909  axis_label = str(ResTxt) + "K"
14910  else:
14911  ResTxt = '{0:.0f}'.format(axisvalue)
14912  axis_label = str(ResTxt)
14913  IAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
14914  IAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
14915  IAca.create_text(xright, y0, text=axis_label, fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
14916  #
14917  i = i + 1
14918  IAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
14919  IAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
14920  RAngle = math.radians(45)
14921  y = TRadius*math.sin(RAngle)
14922  x = TRadius*math.cos(RAngle)
14923  IAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14924  IAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
14925  IAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
14926  IAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
14927  IAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
14928  IAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
14929  else:
14930  # Draw horizontal grid lines
14931  i = 0 - Vdiv.get()
14932  j = 0
14933  x1 = X0LIA
14934  x2 = X0LIA + TRadius * 2
14935  xcenter = x1 + (TRadius)
14936  OhmsperPixel = float(ResScale.get())/Radius
14937  while (i <= Vdiv.get()):
14938  y = Y0TIA + j * (TRadius/Vdiv.get())
14939  Dline = [x1,y,x2,y]
14940  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
14941  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14942  else:
14943  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14944  axisvalue = float(ResScale.get()) * -i
14945  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
14946  axisvalue = axisvalue / 1000
14947  ResTxt = '{0:.1f}'.format(axisvalue)
14948  axis_label = str(ResTxt) + "K"
14949  else:
14950  ResTxt = '{0:.0f}'.format(axisvalue)
14951  axis_label = str(ResTxt)
14952  IAca.create_text(x1-3, y, text=axis_label, fill=COLORtrace6, anchor="e", font=("arial", FontSize ))
14953  i = i + 1
14954  j = j + 1
14955  # Draw vertical grid lines
14956  i = 0 - Vdiv.get()
14957  j = 0
14958  y1 = Y0TIA
14959  y2 = Y0TIA + TRadius * 2
14960  ycenter = y1 + (TRadius)
14961  # "\n".join(axis_label)
14962  while (i <= Vdiv.get()): #
14963  x = x1 + j * (TRadius/Vdiv.get())
14964  Dline = [x,y1,x,y2]
14965  if i == 0 or i == Vdiv.get() or i == -Vdiv.get():
14966  IAca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
14967  else:
14968  IAca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
14969  axisvalue = float(ResScale.get()) * i
14970  if axisvalue >= 1000.0 or axisvalue <= -1000.0:
14971  axisvalue = axisvalue / 1000
14972  ResTxt = '{0:.1f}'.format(axisvalue)
14973  axis_label = str(ResTxt) + "K"
14974  else:
14975  ResTxt = '{0:.0f}'.format(axisvalue)
14976  axis_label = str(ResTxt)
14977  IAca.create_text(x, y2+3, text=axis_label, fill=COLORtrace1, anchor="n", font=("arial", FontSize ))
14978  i = i + 1
14979  j = j + 1
14980 # Draw traces
14981  # Add saved line if there
14982  if IASweepSaved.get() > 0:
14983  if len(TIAMRline) > 4:
14984  IAca.create_line(TIAMRline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
14985 #
14986  x1 = xcenter + ( ImpedanceRseries / OhmsperPixel )
14987  if x1 > 1500:
14988  x1 = xright
14989  elif x1 < -500:
14990  x1 = xcenter - xright
14991  IAca.create_line(xcenter, ycenter, x1, ycenter, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
14992  y1 = ycenter - ( ImpedanceXseries / OhmsperPixel )
14993  if y1 > 1500:
14994  y1 = xright
14995  elif y1 < -500:
14996  y1 = ycenter - xright
14997  xmag = x1
14998  ymag = y1
14999  IAca.create_line(xcenter, ycenter, xcenter, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())
15000  MagRadius = ImpedanceMagnitude / OhmsperPixel
15001  y1 = ycenter - MagRadius*math.sin(math.radians(ImpedanceAngle))
15002  if y1 > 1500:
15003  y1 = xright
15004  elif y1 < -500:
15005  y1 = ycenter - xright
15006  x1 = xcenter + MagRadius*math.cos(math.radians(ImpedanceAngle))
15007  if x1 > 1500:
15008  x1 = xright
15009  elif x1 < -500:
15010  x1 = xcenter - xright
15011  IAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
15012 #
15013  TIAMline = []
15014  if len(NSweepSeriesMag) > 2:
15015  index = 0
15016  while index < len(NSweepSeriesMag):
15017  MagRadius = NSweepSeriesMag[index] / OhmsperPixel
15018  y1 = ycenter - MagRadius*math.sin(math.radians(NSweepSeriesAng[index]))
15019  if y1 > 1500:
15020  y1 = xright
15021  elif y1 < -500:
15022  y1 = ycenter - xright
15023  x1 = xcenter + MagRadius*math.cos(math.radians(NSweepSeriesAng[index]))
15024  if x1 > 1500:
15025  x1 = xright
15026  elif x1 < -500:
15027  x1 = xcenter - xright
15028  TIAMline.append(x1)
15029  TIAMline.append(y1)
15030  index = index + 1
15031  IAca.create_line(TIAMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15032 # display warning if input out of range
15033  if OverRangeFlagA == 1:
15034  x = X0LIA+GRWIA+10
15035  y = Y0TIA+GRHIA-40
15036  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15037  IAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15038  if OverRangeFlagB == 1:
15039  x = X0LIA+GRWIA+10
15040  y = Y0TIA+GRHIA-10
15041  IAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
15042  IAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
15043  # General information on top of the grid
15044 
15045  txt = " Sample rate: " + str(SAMPLErate)
15046  txt = txt + " FFT samples: " + str(SMPfft)
15047 
15048  txt = txt + " " + FFTwindowname
15049 
15050  x = X0LIA
15051  y = 12
15052  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15053  #
15054  x = X0LIA + GRWIA + 4
15055  y = 24
15056  txt = "Gain " + ' {0:.2f} '.format(PeakdbB-PeakdbA) + " dB"
15057  TXT9 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15058  y = y + 24
15059  txt = "Phase " + ' {0:.2f} '.format(PeakRelPhase) + " Degrees"
15060  TXT10 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15061  y = y + 24
15062  txt = "Freq " + ' {0:.1f} '.format(PeakfreqA) + " Hertz"
15063  TXT11 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15064  y = y + 24
15065  txt = "Impedance Magnitude"
15066  TXT1 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15067  y = y + 24
15068  txt = ' {0:.1f} '.format(ImpedanceMagnitude)
15069  TXT2 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15070  y = y + 24
15071  txt = "Impedance Angle"
15072  TXT3 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15073  y = y + 24
15074  txt = ' {0:.1f} '.format(ImpedanceAngle)
15075  TXT4 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15076  y = y + 24
15077  txt = "Impedance R series"
15078  TXT5 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15079  y = y + 24
15080  txt = ' {0:.1f} '.format(ImpedanceRseries)
15081  TXT6 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15082  y = y + 24
15083  txt = "Impedance X series"
15084  TXT7 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15085  y = y + 24
15086  txt = ' {0:.1f} '.format(ImpedanceXseries)
15087  TXT8 = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+6 ))
15088 #
15089  Cseries = 0.0
15090  Cparallel = 0.0
15091  Lseries = 0.0
15092  Lparallel = 0.0
15093  Rparallel = 0.0
15094  if ImpedanceXseries < 0: # calculate series capacitance
15095  y = y + 24
15096  try:
15097  Cseries = -1 / ( 2 * math.pi * PeakfreqA * ImpedanceXseries ) # in farads
15098  except:
15099  Cseries = 0
15100  Qseries = 1/(2*math.pi*PeakfreqA*Cseries*ImpedanceRseries)
15101  Cparallel = Cseries * (Qseries**2 / (1+Qseries**2))
15102  Cparallel = Cparallel * 1E6 # convert to micro Farads
15103  Rparallel = ImpedanceRseries * (1+Qseries**2)
15104  Cseries = Cseries * 1E6 # convert to micro Farads
15105  if DisplaySeries.get() == 0:
15106  txt = "Series Capacitance"
15107  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15108  y = y + 20
15109  if Cseries < 1:
15110  Ctext = Cseries * 1E3
15111  if Ctext < 1:
15112  Ctext = Ctext * 1E3
15113  CtextDis = Ctext + float(CapZeroEntry.get())
15114  txt = ' {0:.1f} '.format(CtextDis) + "pF"
15115  else:
15116  txt = ' {0:.3f} '.format(Ctext) + "nF"
15117  else:
15118  txt = ' {0:.3f} '.format(Cseries) + "uF"
15119  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15120  else:
15121  txt = "Parallel"
15122  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15123  y = y + 20
15124  if Cparallel < 1:
15125  Ctext = Cparallel * 1E3
15126  if Ctext < 1:
15127  Ctext = Ctext * 1E3
15128  txt = "Capacitance " + ' {0:.1f} '.format(Ctext) + "pF"
15129  else:
15130  txt = "Capacitance " + ' {0:.3f} '.format(Ctext) + "nF"
15131  else:
15132  txt = "Capacitance " + ' {0:.3f} '.format(Cparallel) + "uF"
15133  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15134  y = y + 20
15135  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15136  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15137  y = y + 20
15138  dissp = abs(ImpedanceRseries/ImpedanceXseries) * 100 # Dissipation factor is ratio of XR to XC in percent
15139  txt = 'D = {0:.2f} '.format(dissp) + " %"
15140  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15141 
15142  elif ImpedanceXseries > 0: # calculate series inductance
15143  y = y + 24
15144  try:
15145  Lseries = ImpedanceXseries / ( 2 * 3.14159 * PeakfreqA ) # in henry
15146  except:
15147  Lseries = 0
15148  Qseries = (2*math.pi*PeakfreqA*Lseries)/ImpedanceRseries
15149  if Qseries == 0.0: # Check if divide by zero
15150  Qseries = 0.00001
15151  Lparallel = Lseries * ((1+Qseries**2) / Qseries**2)
15152  Lparallel = Lparallel * 1E3 # convert to millihenry
15153  Rparallel = ImpedanceRseries * (1+Qseries**2)
15154  Lseries = Lseries * 1E3 # in millihenry
15155  if DisplaySeries.get() == 0:
15156  txt = "Series Inductance"
15157  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15158  y = y + 22
15159  if Lseries < 1:
15160  Ltext = Lseries * 1E3
15161  txt = ' {0:.2f} '.format(Ltext) + "uH"
15162  else:
15163  txt = ' {0:.2f} '.format(Lseries) + "mH"
15164  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15165  else:
15166  txt = "Parallel"
15167  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15168  y = y + 20
15169  if Lparallel < 1:
15170  Ltext = Lparallel * 1E3
15171  txt = "Inductance " + ' {0:.2f} '.format(Ltext) + "uH"
15172  else:
15173  txt = "Inductance " + ' {0:.2f} '.format(Lparallel) + "mH"
15174  IAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15175  y = y + 20
15176  txt = "Resistance" + ' {0:.1f} '.format(Rparallel) + "ohms"
15177  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15178  y = y + 20
15179  qf = abs(ImpedanceXseries/ImpedanceRseries) * 100 # Quality Factor is ratio of XL to XR
15180  txt = 'Q = {0:.2f} '.format(qf)
15181  IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
15182  #
15183  if LoopNum.get() > 1:
15184  if NetworkScreenStatus.get() > 0:
15185  NSweepSeriesR.append(ImpedanceRseries)
15186  NSweepSeriesX.append(ImpedanceXseries)
15187  NSweepSeriesMag.append(ImpedanceMagnitude) # in ohms
15188  NSweepSeriesAng.append(ImpedanceAngle) # in degrees
15189  NSweepParallelR.append(Rparallel)
15190  NSweepParallelC.append(Cparallel) # in uF
15191  NSweepParallelL.append(Lparallel) # in mH
15192  NSweepSeriesC.append(Cseries) # in uF
15193  NSweepSeriesL.append(Lseries) # in mH
15194  # Start and stop frequency and trace mode
15195  if Two_X_Sample.get() == 0:
15196  txt = "0.0 to 45000 Hz"
15197  else:
15198  txt = "0.0 to 90000 Hz"
15199  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
15200 
15201  x = X0LIA
15202  y = Y0TIA+GRHIA-13
15203  idTXT = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15204  txt = " "
15205  if FreqTraceMode.get() == 1:
15206  txt ="Normal mode "
15207 
15208  if FreqTraceMode.get() == 2:
15209  txt = "Peak hold mode "
15210 
15211  if FreqTraceMode.get() == 3:
15212  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
15213 
15214  if ZEROstuffing.get() > 0:
15215  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
15216  # Runstatus and level information
15217  if (RUNstatus.get() == 0):
15218  txt = txt + " Stopped "
15219  else:
15220  txt = txt + " Running "
15221  y = Y0TIA+GRHIA
15222  IDtxt = IAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
15223 #
15224 def IACaresize(event):
15225  global IAca, GRWIA, XOLIA, GRHIA, Y0TIA, CANVASwidthIA, CANVASheightIA, FontSize
15226 
15227  CANVASwidthIA = event.width - 4
15228  CANVASheightIA = event.height - 4
15229  GRWIA = CANVASwidthIA - (2 * X0LIA) - int(21.25 * FontSize) # 170 new grid width
15230  GRHIA = CANVASheightIA - Y0TIA - int(2.25 * FontSize) # 10 new grid height
15231  UpdateIAAll()
15232 #
15233 # ================ Make IA Window ==========================
15235  global iawindow, IAca, logo, IAScreenStatus, RsystemEntry, IADisp, AWGSync, IASource
15236  global COLORcanvas, CANVASwidthIA, CANVASheightIA, RevDate, AWGAMode, AWGAShape, AWGBMode, AWG_2X
15237  global FFTwindow, CutDC, ColorMode, ResScale, GainCorEntry, PhaseCorEntry, DisplaySeries
15238  global GRWIA, X0LIA, GRHIA, Y0TIA, IA_Ext_Conf, DeBugMode, SWRev, CapZeroEntry
15239  global NetworkScreenStatus, IASweepSaved, IAGridType
15240  global FrameRefief, BorderSize
15241 
15242  if IAScreenStatus.get() == 0:
15243  IAScreenStatus.set(1)
15244  IADisp.set(1)
15245  IACheckBox()
15246  CutDC.set(1) # set to remove DC
15247  CANVASwidthIA = 170 + GRWIA + 2 * X0LIA # The canvas width
15248  CANVASheightIA = GRHIA + Y0TIA + 10 # The canvas height
15249  AWGAMode.set(0) # Set AWG A to SVMI
15250  AWGAShape.set(18) # Set Shape to Bode Sine
15251  ReMakeAWGwaves()
15252  if AWG_2X.get == 1:
15253  AWGBMode.set(0) # Set AWG B to SVMI
15254  else:
15255  AWGBMode.set(2) # Set AWG B to Hi-Z
15256  BAWGAModeLabel()
15257  BAWGBModeLabel()
15258  AWGSync.set(1) # Set AWGs to run sync
15259  iawindow = Toplevel()
15260  iawindow.title("Impedance Analyzer " + SWRev + RevDate)
15261  iawindow.protocol("WM_DELETE_WINDOW", DestroyIAScreen)
15262  frame2iar = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
15263  frame2iar.pack(side=RIGHT, expand=NO, fill=BOTH)
15264 
15265  frame2ia = Frame(iawindow, borderwidth=BorderSize, relief=FrameRefief)
15266  frame2ia.pack(side=TOP, expand=YES, fill=BOTH)
15267 
15268  IAca = Canvas(frame2ia, width=CANVASwidthIA, height=CANVASheightIA, background=COLORcanvas, cursor='cross')
15269  IAca.bind("<Configure>", IACaresize)
15270  IAca.bind("<Return>", DoNothing)
15271  IAca.bind("<space>", onCanvasSpaceBar)
15272  IAca.pack(side=TOP, expand=YES, fill=BOTH)
15273 
15274  # menu buttons
15275  # right side drop down menu buttons
15276  dropmenu = Frame( frame2iar )
15277  dropmenu.pack(side=TOP)
15278  # File menu
15279  IAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15280  IAFilemenu.menu = Menu(IAFilemenu, tearoff = 0 )
15281  IAFilemenu["menu"] = IAFilemenu.menu
15282  IAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
15283  IAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
15284  IAFilemenu.menu.add_command(label="Run Script", command=RunScript)
15285  IAFilemenu.menu.add_command(label="Save V Cal", command=BSaveCal)
15286  IAFilemenu.menu.add_command(label="Load V Cal", command=BLoadCal)
15287  IAFilemenu.menu.add_command(label="Save Data", command=BSaveDataIA)
15288  IAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenIA)
15289  IAFilemenu.menu.add_command(label="Help", command=BHelp)
15290  IAFilemenu.pack(side=LEFT, anchor=W)
15291  #
15292  IAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15293  IAOptionmenu.menu = Menu(IAOptionmenu, tearoff = 0 )
15294  IAOptionmenu["menu"] = IAOptionmenu.menu
15295  IAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15296  IAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15297  IAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15298  IAOptionmenu.menu.add_checkbutton(label='Sweep-on', variable=NetworkScreenStatus)
15299  IAOptionmenu.menu.add_checkbutton(label='Save Sweep', variable=IASweepSaved, command=BSaveIASweep)
15300  if DeBugMode == 1:
15301  IAOptionmenu.menu.add_command(label="-Ext Config-", command=donothing)
15302  IAOptionmenu.menu.add_radiobutton(label='1', variable=IA_Ext_Conf, value=0)
15303  IAOptionmenu.menu.add_radiobutton(label='2', variable=IA_Ext_Conf, value=1)
15304  IAOptionmenu.menu.add_command(label="-Meas As-", command=donothing)
15305  IAOptionmenu.menu.add_radiobutton(label='Series', variable=DisplaySeries, value=0)
15306  IAOptionmenu.menu.add_radiobutton(label='Parallel', variable=DisplaySeries, value=1)
15307  IAOptionmenu.menu.add_command(label="-Background-", command=donothing)
15308  IAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
15309  IAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
15310  IAOptionmenu.pack(side=LEFT, anchor=W)
15311  #
15312  rsemenu = Frame( frame2iar )
15313  rsemenu.pack(side=TOP)
15314  rseb2 = Button(rsemenu, text="Stop", style="Stop.TButton", command=BStop)
15315  rseb2.pack(side=RIGHT)
15316  rseb3 = Button(rsemenu, text="Run", style="Run.TButton", command=BStartIA)
15317  rseb3.pack(side=RIGHT)
15318  #
15319  IAFFTwindmenu = Menubutton(frame2iar, text="FFTwindow", style="W11.TButton")
15320  IAFFTwindmenu.menu = Menu(IAFFTwindmenu, tearoff = 0 )
15321  IAFFTwindmenu["menu"] = IAFFTwindmenu.menu
15322  IAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15323  IAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15324  IAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15325  IAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15326  IAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15327  IAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15328  IAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15329  IAFFTwindmenu.pack(side=TOP)
15330  #
15331  smpmenu = Frame( frame2iar )
15332  smpmenu.pack(side=TOP)
15333  smpb1 = Button(smpmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15334  smpb1.pack(side=LEFT)
15335  smpb2 = Button(smpmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15336  smpb2.pack(side=LEFT)
15337  # Temp set source resistance to 1000
15338  rsystem = Frame( frame2iar )
15339  rsystem.pack(side=TOP)
15340  rsystemlab = Label(rsystem, text="Ext Res")
15341  rsystemlab.pack(side=LEFT, anchor=W)
15342  RsystemEntry = Entry(rsystem, width=7, cursor='double_arrow')
15343  RsystemEntry.bind('<Return>', onTextKey)
15344  RsystemEntry.bind('<MouseWheel>', onTextScroll)
15345  RsystemEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15346  RsystemEntry.bind("<Button-5>", onTextScroll)
15347  RsystemEntry.bind('<Key>', onTextKey)
15348  RsystemEntry.pack(side=LEFT, anchor=W)
15349  RsystemEntry.delete(0,"end")
15350  RsystemEntry.insert(4,1000)
15351  # Res Scale Spinbox
15352  ressb = Frame( frame2iar )
15353  ressb.pack(side=TOP)
15354  reslab = Label(ressb, text="Ohms/div ")
15355  reslab.pack(side=LEFT)
15356  ResScale = Spinbox(ressb, width=7, cursor='double_arrow', values=ResScalediv)
15357  ResScale.bind('<MouseWheel>', onSpinBoxScroll)
15358  ResScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
15359  ResScale.bind("<Button-5>", onSpinBoxScroll)
15360  ResScale.pack(side=LEFT)
15361  ResScale.delete(0,"end")
15362  ResScale.insert(0,500)
15363  #
15364  GainCor = Frame( frame2iar )
15365  GainCor.pack(side=TOP)
15366  GainCorlab = Label(GainCor, text="Gain Cor dB")
15367  GainCorlab.pack(side=LEFT, anchor=W)
15368  GainCorEntry = Entry(GainCor, width=7, cursor='double_arrow')
15369  GainCorEntry.bind('<Return>', onTextKey)
15370  GainCorEntry.bind('<MouseWheel>', onTextScroll)
15371  GainCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15372  GainCorEntry.bind("<Button-5>", onTextScroll)
15373  GainCorEntry.bind('<Key>', onTextKey)
15374  GainCorEntry.pack(side=LEFT, anchor=W)
15375  GainCorEntry.delete(0,"end")
15376  GainCorEntry.insert(4,0.0)
15377  #
15378  PhaseCor = Frame( frame2iar )
15379  PhaseCor.pack(side=TOP)
15380  PhaseCorlab = Label(PhaseCor, text="Phase Cor")
15381  PhaseCorlab.pack(side=LEFT, anchor=W)
15382  PhaseCorEntry = Entry(PhaseCor, width=7, cursor='double_arrow')
15383  PhaseCorEntry.bind('<Return>', onTextKey)
15384  PhaseCorEntry.bind('<MouseWheel>', onTextScroll)
15385  PhaseCorEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15386  PhaseCorEntry.bind("<Button-5>", onTextScroll)
15387  PhaseCorEntry.bind('<Key>', onTextKey)
15388  PhaseCorEntry.pack(side=LEFT, anchor=W)
15389  PhaseCorEntry.delete(0,"end")
15390  PhaseCorEntry.insert(4,0.0)
15391  #
15392  capofflab = Label(frame2iar, text="Capacitance Offset")
15393  capofflab.pack(side=TOP)
15394  CapZero = Frame( frame2iar )
15395  CapZero.pack(side=TOP)
15396  CapZerobutton = Button(CapZero, text="Zero", style="W4.TButton", command=IACapZero)
15397  CapZerobutton.pack(side=LEFT, anchor=W)
15398  CapResetbutton = Button(CapZero, text="Reset", style="W5.TButton", command=IACapReset)
15399  CapResetbutton.pack(side=LEFT, anchor=W)
15400  CapZeroEntry = Entry(CapZero, width=6, cursor='double_arrow')
15401  CapZeroEntry.bind('<Return>', onTextKey)
15402  CapZeroEntry.bind('<MouseWheel>', onTextScroll)
15403  CapZeroEntry.bind("<Button-4>", onTextScroll)# with Linux OS
15404  CapZeroEntry.bind("<Button-5>", onTextScroll)
15405  CapZeroEntry.bind('<Key>', onTextKey)
15406  CapZeroEntry.pack(side=LEFT, anchor=W)
15407  CapZeroEntry.delete(0,"end")
15408  CapZeroEntry.insert(4,0.0)
15409  #
15410  srclab = Label(frame2iar, text="Source")
15411  srclab.pack(side=TOP)
15412  extsrc1 = Radiobutton(frame2iar, text="Internal", variable=IASource, value=0, command=IASourceSet)
15413  extsrc1.pack(side=TOP)
15414  extsrc2 = Radiobutton(frame2iar, text="External", variable=IASource, value=1, command=IASourceSet)
15415  extsrc2.pack(side=TOP)
15416  #
15417  gridmenu = Frame( frame2iar )
15418  gridmenu.pack(side=TOP)
15419  iagrid1= Radiobutton(frame2iar, text="Polar Grid", variable=IAGridType, value=0) #, command=IAGridSet)
15420  iagrid1.pack(side=TOP)
15421  iagrid2 = Radiobutton(frame2iar, text="Rect Grid", variable=IAGridType, value=1) #, command=IAGridSet)
15422  iagrid2.pack(side=TOP)
15423  #
15424  dismiss1button = Button(frame2iar, text="Dismiss", style="W8.TButton", command=DestroyIAScreen)
15425  dismiss1button.pack(side=TOP)
15426  # add ADI logo
15427  ADI1 = Label(frame2iar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
15428  ADI1.pack(side=TOP)
15429 #
15431  global iawindow, IAScreenStatus, IAca, IADisp
15432 
15433  IAScreenStatus.set(0)
15434  IADisp.set(0)
15435  IACheckBox()
15436  iawindow.destroy()
15437 #
15439  global TIAMline, TIAMRline, IASweepSaved
15440 
15441  if IASweepSaved.get() > 0:
15442  TIAMRline = TIAMline
15443 #
15445  global Cseries, CapZeroEntry
15446 
15447  Ctext = ' {0:.1f} '.format(-Cseries * 1E6)
15448  CapZeroEntry.delete(0,"end")
15449  CapZeroEntry.insert(6,Ctext)
15450 #
15452  global CapZeroEntry
15453 
15454  CapZeroEntry.delete(0,"end")
15455  CapZeroEntry.insert(4,0.0)
15456 #
15458  global nqpwindow, NqPca, logo, NqPScreenStatus, NqPDisp
15459  global COLORcanvas, CANVASwidthNqP, CANVASheightNqP, RevDate
15460  global GRWNqP, X0LNqP, GRHNqP, Y0TNqP, DeBugMode, SWRev
15461  global NetworkScreenStatus, NqPSweepSaved
15462  global FrameRefief, BorderSize
15463 
15464  if NqPScreenStatus.get() == 0:
15465  NqPScreenStatus.set(1)
15466  NqPDisp.set(1)
15467  CANVASwidthNqP = GRWNqP + (2 * X0LNqP) # The canvas width
15468  CANVASheightNqP = GRHNqP + Y0TNqP + 10 # The canvas height
15469  nqpwindow = Toplevel()
15470  nqpwindow.title("Nyquist Plot " + SWRev + RevDate)
15471  nqpwindow.protocol("WM_DELETE_WINDOW", DestroyNqPScreen)
15472 
15473  frame2nqp = Frame(nqpwindow, borderwidth=BorderSize, relief=FrameRefief)
15474  frame2nqp.pack(side=TOP, expand=YES, fill=BOTH)
15475 
15476  NqPca = Canvas(frame2nqp, width=CANVASwidthNqP, height=CANVASheightNqP, background=COLORcanvas, cursor='cross')
15477  NqPca.bind("<Configure>", NqPCaresize)
15478  NqPca.bind("<Return>", DoNothing)
15479  NqPca.bind("<space>", onCanvasSpaceBar)
15480  NqPca.pack(side=TOP, expand=YES, fill=BOTH)
15481 #
15483  global nqpwindow, NqPScreenStatus, NqPca, NqPDisp
15484 
15485  NqPScreenStatus.set(0)
15486  NqPDisp.set(0)
15487  nqpwindow.destroy()
15488 #
15489 def NqPCaresize(event):
15490  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, FontSize
15491 
15492  CANVASwidthNqP = event.width - 4
15493  CANVASheightNqP = event.height - 4
15494  GRWNqP = CANVASwidthNqP - (2 * X0LNqP) # new grid width
15495  GRHNqP = CANVASheightNqP - Y0TNqP - int(1.25 * FontSize) # 10 new grid height
15496  UpdateNqPAll()
15497 
15500  global NqPca, GRWNqP, XOLNqP, GRHNqP, Y0TNqP, CANVASwidthNqP, CANVASheightNqP, COLORtrace1
15501  global COLORgrid, GridWidth, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
15502  global FSweepAdB, FSweepBdB, FSweepBPh, FSweepAPh, ShowMathBP, NqPline, Two_X_Sample, TRACEwidth
15503  global Vdiv, FBins, FStep
15504  global FontSize
15505 
15506  # Delete all items on the canvas
15507  NqPca.delete(ALL) # remove all items
15508  SmoothBool = SmoothCurvesBP.get()
15509  # Draw circular grid lines
15510  i = 1
15511  xcenter = GRWNqP/2
15512  ycenter = GRHNqP/2
15513  Radius = (GRWNqP-X0LNqP)/(1 + Vdiv.get() * 2) # 11
15514  dBperPixel = float(DBdivlist[DBdivindexBP.get()])/Radius
15515  TRadius = Radius * Vdiv.get() # 5
15516  x1 = X0LNqP
15517  x2 = X0LNqP + GRWNqP
15518  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
15519  while (i <= Vdiv.get()):
15520  x0 = xcenter - ( i * Radius )
15521  x1 = xcenter + ( i * Radius )
15522  y0 = ycenter - ( i * Radius )
15523  y1 = ycenter + ( i * Radius )
15524  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15525  NqPca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
15526  NqPca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
15527  NqPca.create_text(xright, y0, text=str(dBaxis_value), fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15528  #
15529  i = i + 1
15530  NqPca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
15531  NqPca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
15532  RAngle = math.radians(45)
15533  y = TRadius*math.sin(RAngle)
15534  x = TRadius*math.cos(RAngle)
15535  NqPca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15536  NqPca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
15537  NqPca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
15538  NqPca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
15539  NqPca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
15540  NqPca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
15541  # xcenter = xcenter + (DBlevelBP.get()/dBperPixel)
15542 # Draw traces
15543  NqPline = []
15544  if len(FSweepAdB) > 4:
15545  for index in range(len(FSweepAdB)): # while n < len(FStep):
15546  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
15547  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
15548  else:
15549  F = FBins[int(FStep[0])]
15550  # Mag value
15551  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
15552  dbB = 10 * math.log10(float(FSweepBdB[index]))
15553  if ShowMathBP.get() == 1:
15554  MdB = dbA - dbB
15555  elif ShowMathBP.get() == 2:
15556  MdB = dbB - dbA
15557  MagRadius = (-MdB / dBperPixel) + (DBlevelBP.get()/dBperPixel)
15558  # Phase Value
15559  RelPhase = FSweepBPh[index] - FSweepAPh[index]
15560  if RelPhase > 180:
15561  RelPhase = RelPhase - 360
15562  elif RelPhase < -180:
15563  RelPhase = RelPhase + 360
15564  if Two_X_Sample.get() == 0:
15565  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15566  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
15567  else:
15568  RelPhase = RelPhase # - PhaseOffset2x # - 9.0
15569  y1 = ycenter - MagRadius*math.sin(math.radians(RelPhase))
15570  if y1 > 1500:
15571  y1 = xright
15572  elif y1 < -500:
15573  y1 = ycenter - xright
15574  x1 = xcenter + MagRadius*math.cos(math.radians(RelPhase ))
15575  if x1 > 1500:
15576  x1 = xright
15577  elif x1 < -500:
15578  x1 = xcenter - xright
15579  NqPline.append(x1)
15580  NqPline.append(y1)
15581  NqPca.create_line(NqPline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15582 #
15584  global NiCScreenStatus, NiCDisp
15585  global nicwindow, NiCca, logo, SWRev
15586  global COLORcanvas, CANVASwidthNic, CANVASheightNic, RevDate
15587  global GRWNiC, X0LNiC, GRHNiC, Y0TNiC, DeBugMode
15588  global NetworkScreenStatus, NiCSweepSaved
15589  global FrameRefief, BorderSize
15590 
15591  if NiCScreenStatus.get() == 0:
15592  NiCScreenStatus.set(1)
15593  NiCDisp.set(1)
15594  CANVASwidthNic = GRWNiC + 18 + X0LNiC # The canvas width
15595  CANVASheightNic = GRHNiC + 60 # The canvas height
15596  nicwindow = Toplevel()
15597  nicwindow.title("Nichols Plot " + SWRev + RevDate)
15598  nicwindow.protocol("WM_DELETE_WINDOW", DestroyNiCScreen)
15599 
15600  frame2nic = Frame(nicwindow, borderwidth=BorderSize, relief=FrameRefief)
15601  frame2nic.pack(side=TOP, expand=YES, fill=BOTH)
15602 
15603  NiCca = Canvas(frame2nic, width=CANVASwidthNic, height=CANVASheightNic, background=COLORcanvas, cursor='cross')
15604  NiCca.bind("<Configure>", NiCCaresize)
15605  NiCca.bind("<Return>", DoNothing)
15606  NiCca.bind("<space>", onCanvasSpaceBar)
15607  NiCca.pack(side=TOP, expand=YES, fill=BOTH)
15608 #
15610  global nicwindow, NiCScreenStatus, NiCca, NiCDisp
15611 
15612  NiCScreenStatus.set(0)
15613  NiCDisp.set(0)
15614  nicwindow.destroy()
15615 #
15616 def NiCCaresize(event):
15617  global NiCca, GRWNiC, XOLNiC, GRHNiC, Y0TNiC, CANVASwidthNic, CANVASheightNic, FontSize
15618 
15619  CANVASwidthNic = event.width - 4
15620  CANVASheightNic = event.height - 4
15621  GRWNiC = CANVASwidthNic - int(2.25 * FontSize) - X0LNiC # 18 new grid width
15622  GRHNiC = CANVASheightNic - int(7.5 * FontSize) # 60 new grid height
15623  UpdateNiCAll()
15624 
15627  global NiCline, NiCca, CANVASwidthNic, CANVASheightNic, X0LNiC, GRWNiC, Y0TNiC, GRHNiC, X0TNiC
15628  global COLORzeroline, GridWidth, COLORgrid, FSweepAdB, FSweepBdB, Two_X_Sample, ShowMathBP
15629  global FSweepBPh, FSweepAPh, SmoothCurvesBP, SmoothBool, DBlevelBP, DBdivlist, DBdivindexBP
15630  global Vdiv, FBins, FStep, PhCenBodeEntry, RelPhaseCenter
15631  global FontSize
15632 
15633  Ymin = Y0TNiC # Minimum position of XY grid (top)
15634  Ymax = Y0TNiC + GRHNiC # Maximum position of XY grid (bottom)
15635  Xmin = X0LNiC # Minimum position of XY grid (left)
15636  Xmax = X0LNiC + GRWNiC # Maximum position of XY grid (right)
15637  try:
15638  Phasecenter = int(PhCenBodeEntry.get())
15639  RelPhaseCenter.set(Phasecenter)
15640  except:
15641  PhCenBodeEntry.delete(0,"end")
15642  PhCenBodeEntry.insert(0,0)
15643  RelPhaseCenter.set(0)
15644  Phasecenter = 0
15645  # Delete all items on the screen
15646  MarkerNum = 0
15647  SmoothBool = SmoothCurvesBP.get()
15648  NiCca.delete(ALL) # remove all items
15649  # Draw horizontal grid lines Rel Gain Magnitude
15650  i = 0
15651  x1 = X0LNiC
15652  x2 = X0TNiC = X0LNiC + GRWNiC
15653  mg_siz = GRWNiC/10.0
15654  mg_inc = mg_siz/5.0
15655  DegPerDiv = 360 / 10
15656  while (i < Vdiv.get()+1):
15657  dBaxis_value = (DBlevelBP.get() - (i * DBdivlist[DBdivindexBP.get()]))
15658  y = Y0TNiC + i * GRHNiC/Vdiv.get()
15659  Dline = [x1,y,x2,y]
15660  if dBaxis_value == 0:
15661  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue line at center of grid
15662  k = 0
15663  while (k < 10):
15664  l = 1
15665  while (l < 5): # add tick marks
15666  Dline = [x1+k*mg_siz+l*mg_inc,y-5,x1+k*mg_siz+l*mg_inc,y+5]
15667  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15668  l = l + 1
15669  k = k + 1
15670  else:
15671  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15672  dBaxis_label = str(dBaxis_value)
15673  NiCca.create_text(x1-3, y, text=dBaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
15674 
15675  i = i + 1
15676  # Draw vertical grid lines (phase -180 to 180 10 div)
15677  i = 0
15678  y1 = Y0TNiC
15679  y2 = Y0TNiC + GRHNiC
15680  mg_siz = GRHNiC/10.0
15681  mg_inc = mg_siz/5.0
15682  #
15683  while (i < 11):
15684  x = X0LNiC + i * GRWNiC/10.0
15685  Dline = [x,y1,x,y2]
15686  axis_value = Phasecenter - 180 + (i * DegPerDiv)
15687  axis_label = str(axis_value)
15688  if ( axis_value == 0):
15689  NiCca.create_line(Dline, fill=COLORzeroline, width=GridWidth.get()) # Blue vertical line at center of grid
15690  k = 0
15691  while (k < 10):
15692  l = 1
15693  while (l < 5): # add tick marks
15694  Dline = [x-5,y1+k*mg_siz+l*mg_inc,x+5,y1+k*mg_siz+l*mg_inc]
15695  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15696  l = l + 1
15697  k = k + 1
15698  else:
15699  NiCca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
15700  NiCca.create_text(x, y2+3, text=axis_label, fill=COLORtrace3, anchor="n", font=("arial", FontSize ))
15701  i = i + 1
15702  # Draw traces
15703  # Vertical conversion factors (level dBs) and border limits
15704  Yconv = float(GRHNiC) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
15705  Yc = float(Y0TNiC) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
15706  Xphconv = float(GRWNiC / 360.0) # degrees per pixel
15707  Xp = float(X0LNiC) + Xphconv * 180.0
15708  x1 = X0LNiC + 14
15709  # Horizontal conversion factors (phase deg) and border limits
15710  NiCline = []
15711  if len(FSweepAdB) > 4:
15712  index = 0
15713  for index in range(len(FSweepAdB)): # while n < len(FStep):
15714  if index < len(FStep): # check if n has gone out off bounds because user did something dumb
15715  F = FBins[int(FStep[index])] # look up frequency bin in list of bins
15716  else:
15717  F = FBins[int(FStep[0])]
15718  # Mag value
15719  dbA = 10 * math.log10(float(FSweepAdB[index])) # Convert power to DBs, except for log(0) error
15720  dbB = 10 * math.log10(float(FSweepBdB[index]))
15721  if ShowMathBP.get() == 1:
15722  MdB = dbA - dbB
15723  elif ShowMathBP.get() == 2:
15724  MdB = dbB - dbA
15725  yb = Yc - Yconv * MdB
15726  if (yb < Ymin):
15727  yb = Ymin
15728  if (yb > Ymax):
15729  yb = Ymax
15730  # Phase Value
15731  RelPhase = FSweepBPh[index] - FSweepAPh[index]
15732  RelPhase = RelPhase - Phasecenter
15733  if RelPhase > 180:
15734  RelPhase = RelPhase - 360
15735  elif RelPhase < -180:
15736  RelPhase = RelPhase + 360
15737  if Two_X_Sample.get() == 0:
15738  PhErr = 0.0018 * F # calculate phase error due half sample period offset
15739  RelPhase = RelPhase - PhErr # - PhaseOffset1x # - 12.0
15740  else:
15741  RelPhase = RelPhase # - PhaseOffset2x
15742  xa = Xp + Xphconv * RelPhase
15743  if (xa < Xmin):
15744  xa = Ymin
15745  if (xa > Xmax):
15746  xa = Xmax
15747  NiCline.append(int(xa + 0.5))
15748  NiCline.append(int(yb + 0.5))
15749  NiCca.create_line(NiCline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
15750 #
15751 def UpdateNqPAll(): # Update Data, trace and screen
15752  global FFTBuffA, FFTBuffB
15753  global SMPfft
15754 
15755  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15756  return
15757  #MakeNqPTrace() # Update the traces
15758  UpdateNqPScreen() # Update the screen
15759 
15760 def UpdateNqPTrace(): # Update trace and screen
15761 
15762  #MakeNqPTrace() # Update traces
15763  UpdateNqPScreen() # Update the screen
15764 
15765 def UpdateNqPScreen(): # Update screen with trace and text
15766 
15767  MakeNqPScreen() # Update the screen
15768  root.update() # Activate updated screens
15769 #
15770 def UpdateNiCAll(): # Update Data, trace and screen
15771  global FFTBuffA, FFTBuffB
15772  global SMPfft
15773 
15774  if len(FFTBuffA) < SMPfft and len(FFTBuffB) < SMPfft:
15775  return
15776  #MakeNiCTrace() # Update the traces
15777  UpdateNiCScreen() # Update the screen
15778 
15779 def UpdateNiCTrace(): # Update trace and screen
15780 
15781  #MakeNiCTrace() # Update traces
15782  UpdateNiCScreen() # Update the screen
15783 
15784 def UpdateNiCScreen(): # Update screen with trace and text
15785 
15786  MakeNiCScreen() # Update the screen
15787  root.update() # Activate updated screens
15788 #
15789 #
15790 def VAtoggle():
15791  global vat_btn
15792 
15793  if vat_btn.config('text')[-1] == 'ON':
15794  vat_btn.config(text='OFF', style="Stop.TButton")
15795  else:
15796  vat_btn.config(text='ON', style="Run.TButton")
15797 #
15799  global vabt_btn
15800 
15801  if vabt_btn.config('text')[-1] == 'ON':
15802  vabt_btn.config(text='OFF', style="Stop.TButton")
15803  else:
15804  vabt_btn.config(text='ON', style="Run.TButton")
15805 #
15806 def VBtoggle():
15807  global vbt_btn
15808 
15809  if vbt_btn.config('text')[-1] == 'ON':
15810  vbt_btn.config(text='OFF', style="Stop.TButton")
15811  else:
15812  vbt_btn.config(text='ON', style="Run.TButton")
15813 #
15814 def IAtoggle():
15815  global iat_btn
15816 
15817  if iat_btn.config('text')[-1] == 'ON':
15818  iat_btn.config(text='OFF', style="Stop.TButton")
15819  else:
15820  iat_btn.config(text='ON', style="Run.TButton")
15821 #
15822 def IBtoggle():
15823  global ibt_btn
15824 
15825  if ibt_btn.config('text')[-1] == 'ON':
15826  ibt_btn.config(text='OFF', style="Stop.TButton")
15827  else:
15828  ibt_btn.config(text='ON', style="Run.TButton")
15829 #
15830 # ================ Make Phase Ana Window ==========================
15832  global phawindow, PhAca, logo, PhAScreenStatus, PhADisp, AWGSync
15833  global COLORcanvas, CANVASwidthPhA, CANVASheightPhA, RevDate, AWGAMode, AWGAShape, AWGBMode
15834  global FFTwindow, CutDC, ColorMode, RefPhase, CHvpdiv, CHipdiv
15835  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, DeBugMode, SWRev, PhAPlotMode
15836  global VScale, IScale, RefphEntry, MuxScreenStatus, AppendPhAData
15837  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
15838  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
15839  global FrameRefief, BorderSize
15840 
15841  if PhAScreenStatus.get() == 0:
15842  PhAScreenStatus.set(1)
15843  PhADisp.set(1)
15844  PhACheckBox()
15845  CutDC.set(1) # set to remove DC
15846  CANVASwidthPhA = 170 + GRWPhA + 2 * X0LPhA # The canvas width
15847  CANVASheightPhA = GRHPhA + Y0TPhA + 10 # The canvas height
15848  phawindow = Toplevel()
15849  phawindow.title("Phase Analyzer " + SWRev + RevDate)
15850  phawindow.protocol("WM_DELETE_WINDOW", DestroyPhAScreen)
15851  frame2phar = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
15852  frame2phar.pack(side=RIGHT, expand=NO, fill=BOTH)
15853 
15854  frame2pha = Frame(phawindow, borderwidth=BorderSize, relief=FrameRefief)
15855  frame2pha.pack(side=TOP, expand=YES, fill=BOTH)
15856 
15857  PhAca = Canvas(frame2pha, width=CANVASwidthPhA, height=CANVASheightPhA, background=COLORcanvas, cursor='cross')
15858  PhAca.bind("<Configure>", PhACaresize)
15859  PhAca.bind("<Return>", DoNothing)
15860  PhAca.bind("<space>", onCanvasSpaceBar)
15861  PhAca.pack(side=TOP, expand=YES, fill=BOTH)
15862 
15863  if MuxScreenStatus.get() == 0:
15864  RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
15865  else:
15866  RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
15867  # menu buttons
15868  # right side drop down menu buttons
15869  dropmenu = Frame( frame2phar )
15870  dropmenu.pack(side=TOP)
15871  # File menu
15872  PhAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
15873  PhAFilemenu.menu = Menu(PhAFilemenu, tearoff = 0 )
15874  PhAFilemenu["menu"] = PhAFilemenu.menu
15875  PhAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigIA)
15876  PhAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigIA)
15877  PhAFilemenu.menu.add_command(label="Run Script", command=RunScript)
15878  PhAFilemenu.menu.add_command(label="Save Data", command=BSavePhAData)
15879  PhAFilemenu.menu.add_checkbutton(label=' - Append', variable=AppendPhAData)
15880  PhAFilemenu.menu.add_command(label="Plot From File", command=PlotPhAFromFile)
15881  PhAFilemenu.menu.add_radiobutton(label=' - Vectors', variable=PhAPlotMode, value=0)
15882  PhAFilemenu.menu.add_radiobutton(label=' - Outline', variable=PhAPlotMode, value=1)
15883  PhAFilemenu.menu.add_command(label="Help", command=BHelp)
15884  PhAFilemenu.pack(side=LEFT, anchor=W)
15885  #
15886  PhAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
15887  PhAOptionmenu.menu = Menu(PhAOptionmenu, tearoff = 0 )
15888  PhAOptionmenu["menu"] = PhAOptionmenu.menu
15889  PhAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
15890  PhAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
15891  PhAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
15892 
15893  PhAOptionmenu.menu.add_command(label="-Background-", command=donothing)
15894  PhAOptionmenu.menu.add_radiobutton(label='Black', variable=ColorMode, value=0, command=BgColor)
15895  PhAOptionmenu.menu.add_radiobutton(label='White', variable=ColorMode, value=1, command=BgColor)
15896  PhAOptionmenu.pack(side=LEFT, anchor=W)
15897  #
15898  rsphmenu = Frame( frame2phar )
15899  rsphmenu.pack(side=TOP)
15900  rsphb2 = Button(rsphmenu, text="Stop", style="Stop.TButton", command=BStop)
15901  rsphb2.pack(side=RIGHT)
15902  rsphb3 = Button(rsphmenu, text="Run", style="Run.TButton", command=BStart)
15903  rsphb3.pack(side=RIGHT)
15904  #
15905  PhAFFTwindmenu = Menubutton(frame2phar, text="FFTwindow", style="W11.TButton")
15906  PhAFFTwindmenu.menu = Menu(PhAFFTwindmenu, tearoff = 0 )
15907  PhAFFTwindmenu["menu"] = PhAFFTwindmenu.menu
15908  PhAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
15909  PhAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
15910  PhAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
15911  PhAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
15912  PhAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
15913  PhAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
15914  PhAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
15915  PhAFFTwindmenu.pack(side=TOP)
15916  #
15917  FFTwindow.set(6) # default to Flat top window (6)
15918  #
15919  smphmenu = Frame( frame2phar )
15920  smphmenu.pack(side=TOP)
15921  smphb1 = Button(smphmenu, text="-Samples", style="W8.TButton", command=Bsamples1)
15922  smphb1.pack(side=LEFT)
15923  smphb2 = Button(smphmenu, text="+Samples", style="W8.TButton", command=Bsamples2)
15924  smphb2.pack(side=LEFT)
15925  #
15926  refph = Frame( frame2phar )
15927  refph.pack(side=TOP)
15928  refphlab = Label(refph, text="Ref Phase")
15929  refphlab.pack(side=LEFT, anchor=W)
15930  RefphEntry = Spinbox(refph, width=5, cursor='double_arrow', values=RefPhase)
15931  RefphEntry.bind('<MouseWheel>', onSpinBoxScroll)
15932  RefphEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
15933  RefphEntry.bind("<Button-5>", onSpinBoxScroll)
15934  RefphEntry.pack(side=LEFT, anchor=W)
15935  RefphEntry.delete(0,"end")
15936  RefphEntry.insert(0,"CA-V")
15937  vatb = Frame( frame2phar )
15938  vatb.pack(side=TOP)
15939  vatblab = Label(vatb, text="CA-V ")
15940  vatblab.pack(side=LEFT)
15941  vat_btn = Button(vatb, text="OFF", style="Stop.TButton", width=4, command=VAtoggle)
15942  vat_btn.pack(side=LEFT)
15943  vbtb = Frame( frame2phar )
15944  vbtb.pack(side=TOP)
15945  if MuxScreenStatus.get() == 0:
15946  #RefPhase = ("CA-V", "CB-V", "CA-I", "CB-I")
15947  vbtblab = Label(vbtb, text="CB-V ")
15948  vbtblab.pack(side=LEFT)
15949  vbt_btn = Button(vbtb, text="OFF", style="Stop.TButton", width=4, command=VBtoggle)
15950  vbt_btn.pack(side=LEFT)
15951  vabtb = Frame( frame2phar )
15952  vabtb.pack(side=TOP)
15953  vabtblab = Label(vabtb, text="CA-B V ")
15954  vabtblab.pack(side=LEFT)
15955  vabt_btn = Button(vabtb, text="OFF", style="Stop.TButton", width=4, command=VABtoggle)
15956  vabt_btn.pack(side=LEFT)
15957  else:
15958  #RefphEntry.configure(state=DISABLED)
15959  #RefPhase = ("CA-V", "CB-A", "CB-B", "CB-C", "CB-D","CA-I", "CB-I")
15960  amuxlab = Label(frame2phar, text="Analog Mux In")
15961  amuxlab.pack(side=TOP)
15962  phbt1 = Checkbutton(frame2phar, text='CB-A ', style="Strace2.TCheckbutton", variable=ShowPB_A)
15963  phbt1.pack(side=TOP)
15964  phbt2 = Checkbutton(frame2phar, text='CB-B ', style="Strace6.TCheckbutton", variable=ShowPB_B) #, command=TraceSelectADC_Mux)
15965  phbt2.pack(side=TOP)
15966  phbt3 = Checkbutton(frame2phar, text='CB-C ', style="Strace7.TCheckbutton", variable=ShowPB_C) #, command=TraceSelectADC_Mux)
15967  phbt3.pack(side=TOP)
15968  phbt4 = Checkbutton(frame2phar, text='CB-D ', style="Strace4.TCheckbutton", variable=ShowPB_D) #, command=TraceSelectADC_Mux)
15969  phbt4.pack(side=TOP)
15970 #
15971  # Voltage Scale Spinbox
15972  vssb = Frame( frame2phar )
15973  vssb.pack(side=TOP)
15974  vslab = Label(vssb, text="Volts/div ")
15975  vslab.pack(side=LEFT)
15976  VScale = Spinbox(vssb, width=7, cursor='double_arrow', values=CHvpdiv)
15977  VScale.bind('<MouseWheel>', onSpinBoxScroll)
15978  VScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
15979  VScale.bind("<Button-5>", onSpinBoxScroll)
15980  VScale.pack(side=LEFT)
15981  VScale.delete(0,"end")
15982  VScale.insert(0,0.5)
15983  #
15984  iatb = Frame( frame2phar )
15985  iatb.pack(side=TOP)
15986  iatblab = Label(iatb, text="CA-I ")
15987  iatblab.pack(side=LEFT)
15988  iat_btn = Button(iatb, text="OFF", style="Stop.TButton", width=4, command=IAtoggle)
15989  iat_btn.pack(side=LEFT)
15990  ibtb = Frame( frame2phar )
15991  ibtb.pack(side=TOP)
15992  ibtblab = Label(ibtb, text="CB-I ")
15993  ibtblab.pack(side=LEFT)
15994  ibt_btn = Button(ibtb, text="OFF", style="Stop.TButton", width=4, command=IBtoggle)
15995  ibt_btn.pack(side=LEFT)
15996  # Current Scale Spinbox
15997  issb = Frame( frame2phar )
15998  issb.pack(side=TOP)
15999  islab = Label(issb, text="mA/div ")
16000  islab.pack(side=LEFT)
16001  IScale = Spinbox(issb, width=7, cursor='double_arrow', values=CHipdiv)
16002  IScale.bind('<MouseWheel>', onSpinBoxScroll)
16003  IScale.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
16004  IScale.bind("<Button-5>", onSpinBoxScroll)
16005  IScale.pack(side=LEFT)
16006  IScale.delete(0,"end")
16007  IScale.insert(0,10.0)
16008 
16009  dismiss1button = Button(frame2phar, text="Dismiss", style="W8.TButton", command=DestroyPhAScreen)
16010  dismiss1button.pack(side=TOP)
16011  # add ADI logo
16012  ADI1 = Label(frame2phar, image=logo, anchor= "sw", compound="top") # height=49, width=116,
16013  ADI1.pack(side=TOP)
16014 #
16015 # Destroy Phase Analizer window
16017  global phawindow, PhAScreenStatus, PhAca, PhADisp
16018 
16019  PhAScreenStatus.set(0)
16020  PhADisp.set(0)
16021  PhACheckBox()
16022  phawindow.destroy()
16023 #
16024 # Resize Phase Analizer window
16025 def PhACaresize(event):
16026  global PhAca, GRWPhA, XOLPhA, GRHPhA, Y0TPhA, CANVASwidthPhA, CANVASheightPhA, FontSize
16027 
16028  CANVASwidthPhA = event.width - 4
16029  CANVASheightPhA = event.height - 4
16030  GRWPhA = CANVASwidthPhA - (2 * X0LPhA) - int(21.25 * FontSize) # 170 new grid width
16031  GRHPhA = CANVASheightPhA - Y0TPhA - int(2.25 * FontSize) # 10 new grid height
16032  UpdatePhAAll()
16033 #
16034 def UpdatePhAAll(): # Update Data, trace and screen
16035 
16036  MakePhATrace() # Update the traces
16037  UpdatePhAScreen() # Update the screen
16038 
16039 def UpdatePhATrace(): # Update trace and screen
16040  MakePhATrace() # Update traces
16041  UpdatePhAScreen() # Update the screen
16042 
16043 def UpdatePhAScreen(): # Update screen with trace and text
16044  MakePhAScreen() # Update the screen
16045  root.update() # Activate updated screens
16046 #
16047 # Place holder
16048 def MakePhATrace(): # Update the grid and trace
16049  global VAresult, VBresult, IAresult, IBresult, VABresult, PhaseIA, PhaseIB, PhaseVA, PhaseVB, PhaseVAB
16050  global VMAresult, VMBresult, VMCresult, VMDresult, PhaseVMD, PhaseVMA, PhaseVMB, PhaseVMC
16051  global PeakVA, PeakVB, PeakIA, PeakIB, PeakVAB
16052  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16053  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16054  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB, PeakphaseVAB
16055  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16056  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16057  global GRHPhA # Screenheight
16058  global GRWPhA # Screenwidth
16059  global AWGSAMPLErate, SAMPLErate, BaseSampleRate
16060  global STARTsample, STOPsample, LoopNum, FSweepMode
16061  global TRACEmode, Two_X_Sample, MuxScreenStatus, MuxChan, ChopMuxMode
16062  global Vdiv # Number of vertical divisions
16063  global X0LPhA # Left top X value
16064  global Y0TPhA # Left top Y value
16065 
16066  # Set the TRACEsize variable
16067  if len(VAresult) < 32:
16068  return
16069  TRACEsize = len(VAresult) # Set the trace length
16070  Fsample = float(SAMPLErate / 2) / (TRACEsize - 1)
16071  # Horizontal conversion factors (frequency Hz) and border limits
16072  STARTsample = 0 # First sample in FFTresult[] that is used
16073  STARTsample = int(math.ceil(STARTsample)) # First within screen range
16074  if Two_X_Sample.get() == 0:
16075  STOPsample = 45000 / Fsample # Last sample in FFTresult that is used
16076  else:
16077  STOPsample = 90000 / Fsample
16078  STOPsample = int(math.floor(STOPsample)) # Last within screen range, math.floor actually not necessary, part of int
16079 #
16080 
16081  MAXsample = TRACEsize # Just an out of range check
16082  if STARTsample > (MAXsample - 1):
16083  STARTsample = MAXsample - 1
16084 
16085  if STOPsample > MAXsample:
16086  STOPsample = MAXsample
16087 
16088  n = STARTsample +1
16089  PeakVA = PeakVB = PeakIA = PeakIB = PeakVAB = 0.0
16090  PeakfreqVA = PeakfreqVB = PeakfreqIA = PeakfreqIB = F = n * Fsample
16091  PeakphaseVA = PhaseVA[n]
16092  if MuxScreenStatus.get() == 0:
16093  PeakphaseVB = PhaseVB[n]
16094  else:
16095  PeakphaseVMA = PeakphaseVMB = PeakphaseVMC = PeakphaseVMD = 0.0
16096  PeakphaseIA = PhaseIA[n]
16097  PeakphaseIB = PhaseIB[n]
16098  PeakSampleVB = PeakSampleVA = PeakSampleIA = PeakSampleIB = n
16099  PeakSampleVMA = PeakSampleVMB = PeakSampleVMC = PeakSampleVMD = n
16100  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16101  PeakVMA = 0
16102  PeakphaseVMA = PhaseVMA[n]
16103  PeakSampleVMA = 0
16104  PeakfreqVMA = PeakfreqVA
16105  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16106  PeakVMB = 0
16107  PeakphaseVMB = PhaseVMB[n]
16108  PeakSampleVMB = 0
16109  PeakfreqVMB = PeakfreqVA
16110  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16111  PeakVMC = 0
16112  PeakphaseVMC = PhaseVMC[n]
16113  PeakSampleVMC = 0
16114  PeakfreqVMC = PeakfreqVA
16115  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16116  PeakVMD = 0
16117  PeakphaseVMD = PhaseVMD[n]
16118  PeakSampleVMD = 0
16119  PeakfreqVMD = PeakfreqVA
16120 
16121  while n <= STOPsample: # search for peaks
16122  F = n * Fsample
16123  try:
16124  VA = float(VAresult[n]) #
16125  except:
16126  VA = 0.0
16127  if VA > PeakVA:
16128  PeakVA = VA
16129  PeakfreqVA = F
16130  PeakphaseVA = PhaseVA[n]
16131  PeakSampleVA = n
16132 
16133  if MuxScreenStatus.get() == 0:
16134  try:
16135  VAB = float(VABresult[n]) #
16136  except:
16137  VAB = 0.0
16138  if VAB > PeakVAB:
16139  PeakVAB = VAB
16140  PeakfreqVAB = F
16141  PeakphaseVAB = PhaseVAB[n]
16142  PeakSampleVAB = n
16143 
16144  try:
16145  VB = float(VBresult[n]) #
16146  except:
16147  VB = 0.0
16148  if VB > PeakVB:
16149  PeakVB = VB
16150  PeakfreqVB = F
16151  PeakphaseVB = PhaseVB[n]
16152  PeakSampleVB = n
16153  else:
16154  if MuxChan == 0 or ChopMuxMode.get() > 0: #
16155  try:
16156  VMA = float(VMAresult[n]) #
16157  except:
16158  VMA = 0.0
16159  if VMA > PeakVMA:
16160  PeakVMA = VMA
16161  PeakfreqVMA = F
16162  PeakphaseVMA = PhaseVMA[n]
16163  PeakSampleVMA = n
16164  if MuxChan == 1 or ChopMuxMode.get() > 0: #
16165  try:
16166  VMB = float(VMBresult[n]) #
16167  except:
16168  VMB = 0.0
16169  if VMB > PeakVMB:
16170  PeakVMB = VMB
16171  PeakfreqVMB = F
16172  PeakphaseVMB = PhaseVMB[n]
16173  PeakSampleVMB = n
16174  if MuxChan == 2 or ChopMuxMode.get() > 0: #
16175  try:
16176  VMC = float(VMCresult[n]) #
16177  except:
16178  VMC = 0.0
16179  if VMC > PeakVMC:
16180  PeakVMC = VMC
16181  PeakfreqVMC = F
16182  PeakphaseVMC = PhaseVMC[n]
16183  PeakSampleVMC = n
16184  if MuxChan == 3 or ChopMuxMode.get() > 0: #
16185  try:
16186  VMD = float(VMDresult[n]) #
16187  except:
16188  VMD = 0.0
16189  if VMD > PeakVMD:
16190  PeakVMD = VMD
16191  PeakfreqVMD = F
16192  PeakphaseVMD = PhaseVMD[n]
16193  PeakSampleVMD = n
16194  try:
16195  IA = float(IAresult[n]) #
16196  except:
16197  IA = 0.0
16198  if IA > PeakIA:
16199  PeakIA = IA
16200  PeakfreqIA = F
16201  PeakphaseIA = PhaseIA[n]
16202  PeakSampleIA = n
16203 
16204  try:
16205  IB = float(IBresult[n]) #
16206  except:
16207  IB = 0.0
16208  if IB > PeakIB:
16209  PeakIB = IB
16210  PeakfreqIB = F
16211  PeakphaseIB = PhaseIB[n]
16212  PeakSampleIB = n
16213 
16214  n = n + 1
16215  # Check to see that V, Vnux and I peaks are in same frequency bin?
16216  if PeakSampleVA != PeakSampleIA:
16217  PeakphaseIA = PhaseIA[PeakSampleVA]
16218  PeakIA = IAresult[PeakSampleVA]
16219  if PeakSampleVB != PeakSampleIB and MuxScreenStatus.get() == 0:
16220  PeakphaseIB = PhaseIB[PeakSampleVB]
16221  PeakIB = IBresult[PeakSampleVB]
16222  if MuxScreenStatus.get() > 0:
16223  if PeakSampleVA != PeakSampleVMA:
16224  try:
16225  PeakphaseVMA = PhaseVMA[PeakSampleVA]
16226  PeakVMA = float(VMAresult[PeakSampleVA])
16227  except:
16228  donothing()
16229  if PeakSampleVA != PeakSampleVMB:
16230  try:
16231  PeakphaseVMB = PhaseVMB[PeakSampleVA]
16232  PeakVMB = float(VMBresult[PeakSampleVA])
16233  except:
16234  donothing()
16235  if PeakSampleVA != PeakSampleVMC:
16236  try:
16237  PeakphaseVMC = PhaseVMC[PeakSampleVA]
16238  PeakVMC = float(VMCresult[PeakSampleVA])
16239  except:
16240  donothing()
16241  if PeakSampleVA != PeakSampleVMD:
16242  try:
16243  PeakphaseVMD = PhaseVMD[PeakSampleVA]
16244  PeakVMD = float(VMDresult[PeakSampleVA])
16245  except:
16246  donothing()
16247 #
16248 # Draw the Phase Analyzer screen
16249 def MakePhAScreen(): # Update the screen with traces and text
16250  global PeakVA, PeakVB, PeakIA, PeakIB
16251  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16252  global PeakphaseVA, PeakphaseVB, PeakphaseIA, PeakphaseIB
16253  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16254  global PeakphaseVMA, PeakphaseVMB, PeakphaseVMC, PeakphaseVMD
16255  global PeakfreqVMA, PeakfreqVMB, PeakfreqVMC, PeakfreqVMD
16256  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
16257  global CMAphase, CMBphase, CMCphase, CMDphase
16258  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth
16259  global COLORsignalband, COLORtext, COLORgrid # The colors
16260  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
16261  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
16262  global X0LPhA # Left top X value
16263  global Y0TPhA # Left top Y value
16264  global GRWPhA # Screenwidth
16265  global GRHPhA # Screenheight
16266  global FontSize, MuxScreenStatus, MuxChan, Mulx, ChopMuxMode
16267  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
16268  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, OverRangeFlagA, OverRangeFlagB
16269  global SMPfft # number of FFT samples
16270  global TRACEaverage # Number of traces for averageing
16271  global FreqTraceMode # 1 normal 2 max 3 average
16272  global Vdiv, VScale, IScale # Number of vertical divisions
16273  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
16274  global AWGBMode, AWGBIOMode, ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
16275  global ShowC1_V, ShowC2_V, ShowC1_I, ShowC2_I, CHA_RC_HP, CHB_RC_HP
16276  global DCV1, DCV2, MinV1, MaxV1, MinV2, MaxV2, CHAHW, CHALW, CHADCy, CHAperiod, CHAfreq
16277  global DCI1, DCI2, MinI1, MaxI1, MinI2, MaxI2, CHBHW, CHBLW, CHBDCy, CHBperiod, CHBfreq
16278  global InOffA, InGainA, InOffB, InGainB
16279  global CurOffA, CurOffB, CurGainA, CurGainB
16280  # Analog Mux channel measurement variables
16281  global DCVMuxA, MinVMuxA, MaxVMuxA, MidVMuxA, PPVMuxA, SVMuxA
16282  global DCVMuxB, MinVMuxB, MaxVMuxB, MidVMuxB, PPVMuxB, SVMuxB
16283  global DCVMuxC, MinVMuxC, MaxVMuxC, MidVMuxC, PPVMuxC, SVMuxC
16284  global DCVMuxD, MinVMuxD, MaxVMuxD, MidVMuxD, PPVMuxD, SVMuxD
16285  global SV1, SI1, SV2, SI2, CHABphase, SVA_B
16286  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1
16287  global MeasDCI1, MeasMinI1, MeasMaxI1, MeasMidI1, MeasPPI1
16288  global MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2, MeasPPV2
16289  global MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2
16290  global MeasRMSV1, MeasRMSI1, MeasRMSV2, MeasRMSI2, MeasPhase, MeasRMSVA_B
16291  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ
16292  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
16293 
16294  # Delete all items on the screen
16295  PhAca.delete(ALL) # remove all items
16296  # SmoothBool = SmoothCurvesBP.get()
16297  # Draw circular grid lines
16298  i = 1
16299  xcenter = GRWPhA/2
16300  ycenter = (GRHPhA/2) + 14
16301  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
16302  VoltsperPixel = float(VScale.get())/Radius
16303  mAperPixel = float(IScale.get())/Radius
16304  TRadius = Radius * Vdiv.get() # 5
16305  x1 = X0LPhA
16306  x2 = X0LPhA + GRWPhA
16307  xright = 10 + xcenter + ( Vdiv.get() * Radius ) # 5
16308  while (i <= Vdiv.get()):
16309  x0 = xcenter - ( i * Radius )
16310  x1 = xcenter + ( i * Radius )
16311  y0 = ycenter - ( i * Radius )
16312  y1 = ycenter + ( i * Radius )
16313  VTxt = '{0:.2f}'.format(float(VScale.get()) * i)
16314  ITxt = '{0:.2f}'.format(float(IScale.get()) * i)
16315  TOffset = xright+(4*FontSize)
16316  PhAca.create_oval( x0, y0, x1, y1, outline=COLORgrid, width=GridWidth.get())
16317  PhAca.create_line(xcenter, y0, xright, y0, fill=COLORgrid, width=GridWidth.get(), dash=(4,3))
16318  PhAca.create_text(xright, y0, text=str(VTxt), fill=COLORtrace1, anchor="w", font=("arial", FontSize+2 ))
16319  if iat_btn.config('text')[-1] == 'ON' or ibt_btn.config('text')[-1] == 'ON':
16320  PhAca.create_text(TOffset, y0, text=str(ITxt), fill=COLORtrace3, anchor="w", font=("arial", FontSize+2 ))
16321  #
16322  i = i + 1
16323  PhAca.create_line(xcenter, y0, xcenter, y1, fill=COLORgrid, width=GridWidth.get())
16324  PhAca.create_line(x0, ycenter, x1, ycenter, fill=COLORgrid, width=GridWidth.get())
16325  RAngle = math.radians(45)
16326  y = TRadius*math.sin(RAngle)
16327  x = TRadius*math.cos(RAngle)
16328  PhAca.create_line(xcenter-x, ycenter-y, xcenter+x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16329  PhAca.create_line(xcenter+x, ycenter-y, xcenter-x, ycenter+y, fill=COLORgrid, width=GridWidth.get())
16330  PhAca.create_text(x0, ycenter, text="180", fill=COLORgrid, anchor="e", font=("arial", FontSize+2 ))
16331  PhAca.create_text(x1, ycenter, text="0.0", fill=COLORgrid, anchor="w", font=("arial", FontSize+2 ))
16332  PhAca.create_text(xcenter, y0, text="90", fill=COLORgrid, anchor="s", font=("arial", FontSize+2 ))
16333  PhAca.create_text(xcenter, y1, text="-90", fill=COLORgrid, anchor="n", font=("arial", FontSize+2 ))
16334  YBot = y1
16335  # calculate phase error due half sample period offset 0.0018
16336  if Two_X_Sample.get() == 0:
16337  if AWGBMode.get() == 2 or AWGBIOMode.get() > 0:
16338  PhErr = 0.001675 * PeakfreqVA
16339  PhErrMA = PhErr
16340  PhErrMB = PhErr
16341  PhErrMC = PhErr
16342  PhErrMD = PhErr
16343  else:
16344  PhErr = 0.0
16345  PhErrMA = PhErr
16346  PhErrMB = PhErr
16347  PhErrMC = PhErr
16348  PhErrMD = PhErr
16349  else:
16350  PhErr = 0.0
16351  PhErrMA = PhErr
16352  PhErrMB = PhErr
16353  PhErrMC = PhErr
16354  PhErrMD = PhErr
16355  if ChopMuxMode.get() > 0:
16356  PhErrMB = 0.0072 * PeakfreqVMB
16357  PhErrMA = 0.0016 * PeakfreqVMA #
16358  PhErrMD = 0.0054 * PeakfreqVMD
16359  PhErrMC = 0.0016 * PeakfreqVMC #
16360 # Draw traces
16361 #
16362  if RefphEntry.get() == "CA-V":
16363  CAVphase = 0.0
16364  CBVphase = PeakphaseVA - PeakphaseVB + PhErr
16365  CAIphase = PeakphaseVA - PeakphaseIA
16366  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
16367  CABVphase = PeakphaseVA - PeakphaseVAB
16368  elif RefphEntry.get() == "CB-V":
16369  CBVphase = 0.0
16370  CAVphase = PeakphaseVB - PeakphaseVA - PhErr
16371  CAIphase = PeakphaseVB - PeakphaseIA - PhErr
16372  CBIphase = PeakphaseVB - PeakphaseIB
16373  CABVphase = PeakphaseVB - PeakphaseVAB
16374  elif RefphEntry.get() == "CA-I":
16375  CAIphase = 0.0
16376  CAVphase = PeakphaseIA - PeakphaseVA
16377  CBVphase = PeakphaseIA - PeakphaseVB + PhErr
16378  CBIphase = PeakphaseIA - PeakphaseIB + PhErr
16379  CABVphase = PeakphaseIA - PeakphaseVAB
16380  elif RefphEntry.get() == "CB-I":
16381  CBIphase = 0.0
16382  CAVphase = PeakphaseIB - PeakphaseVA - PhErr
16383  CBVphase = PeakphaseIB - PeakphaseVB
16384  CAIphase = PeakphaseIB - PeakphaseIA - PhErr
16385  CABVphase = PeakphaseIB - PeakphaseVAB
16386  #
16387  if MuxScreenStatus.get() > 0:
16388  CBVphase = 0.0
16389  if RefphEntry.get() == "CA-V":
16390  CAVphase = 0.0
16391  CMAphase = PeakphaseVA - PeakphaseVMA + PhErr
16392  CMBphase = PeakphaseVA - PeakphaseVMB + PhErr
16393  CMCphase = PeakphaseVA - PeakphaseVMC + PhErr
16394  CMDphase = PeakphaseVA - PeakphaseVMD + PhErr
16395  CAIphase = PeakphaseVA - PeakphaseIA
16396  CBIphase = PeakphaseVA - PeakphaseIB + PhErr
16397  elif RefphEntry.get() == "CB-A":
16398  CMAphase = 0.0
16399  CAVphase = PeakphaseVMA - PeakphaseVA + PhErr
16400  CMBphase = PeakphaseVMA - PeakphaseVMB - PhErrMB
16401  CMCphase = PeakphaseVMA - PeakphaseVMC + PhErrMC
16402  CMDphase = PeakphaseVMA - PeakphaseVMD - PhErrMD
16403  CAIphase = PeakphaseVMA - PeakphaseIA
16404  CBIphase = PeakphaseVMA - PeakphaseIB + PhErr
16405  elif RefphEntry.get() == "CB-B":
16406  CMBphase = 0.0
16407  CAVphase = PeakphaseVMB - PeakphaseVA + PhErr
16408  CMAphase = PeakphaseVMB - PeakphaseVMA + PhErrMD
16409  CMCphase = PeakphaseVMB - PeakphaseVMC + PhErrMB
16410  CMDphase = PeakphaseVMB - PeakphaseVMD + PhErrMC
16411  CAIphase = PeakphaseVMB - PeakphaseIA
16412  CBIphase = PeakphaseVMB - PeakphaseIB + PhErr
16413  elif RefphEntry.get() == "CB-C":
16414  CMCphase = 0.0
16415  CAVphase = PeakphaseVMC - PeakphaseVA + PhErr
16416  CMAphase = PeakphaseVMC - PeakphaseVMA + PhErrMC
16417  CMBphase = PeakphaseVMC - PeakphaseVMB - PhErrMB
16418  CMDphase = PeakphaseVMC - PeakphaseVMD - PhErrMD
16419  CAIphase = PeakphaseVMC - PeakphaseIA
16420  CBIphase = PeakphaseVMC - PeakphaseIB + PhErr
16421  elif RefphEntry.get() == "CB-D":
16422  CMDphase = 0.0
16423  CAVphase = PeakphaseVMD - PeakphaseVA + PhErr
16424  CMAphase = PeakphaseVMD - PeakphaseVMA + PhErrMD
16425  CMBphase = PeakphaseVMD - PeakphaseVMB + PhErrMC
16426  CMCphase = PeakphaseVMD - PeakphaseVMC + PhErrMD
16427  CAIphase = PeakphaseVMD - PeakphaseIA
16428  CBIphase = PeakphaseVMD - PeakphaseIB + PhErr
16429 
16430  if CAVphase > 180:
16431  CAVphase = CAVphase - 360
16432  elif CAVphase < -180:
16433  CAVphase = CAVphase + 360
16434  if CBVphase > 180:
16435  CBVphase = CBVphase - 360
16436  elif CBVphase < -180:
16437  CBVphase = CBVphase + 360
16438  if CAIphase > 180:
16439  CAIphase = CAIphase - 360
16440  elif CAIphase < -180:
16441  CAIphase = CAIphase + 360
16442  if CBIphase > 180:
16443  CBIphase = CBIphase - 360
16444  elif CBIphase < -180:
16445  CBIphase = CBIphase + 360
16446  #
16447  if vat_btn.config('text')[-1] == 'ON':
16448  MagRadius = PeakVA / VoltsperPixel
16449  y1 = ycenter - MagRadius*math.sin(math.radians(CAVphase))
16450  if y1 > 1500:
16451  y1 = xright
16452  elif y1 < -500:
16453  y1 = ycenter - xright
16454  x1 = xcenter + MagRadius*math.cos(math.radians(CAVphase))
16455  if x1 > 1500:
16456  x1 = xright
16457  elif x1 < -500:
16458  x1 = xcenter - xright
16459  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace1, arrow="last", width=TRACEwidth.get())
16460  if MuxScreenStatus.get() == 0:
16461  if vbt_btn.config('text')[-1] == 'ON':
16462  MagRadius = PeakVB / VoltsperPixel
16463  y1 = ycenter - MagRadius*math.sin(math.radians(CBVphase))
16464  if y1 > 1500:
16465  y1 = xright
16466  elif y1 < -500:
16467  y1 = ycenter - xright
16468  x1 = xcenter + MagRadius*math.cos(math.radians(CBVphase))
16469  if x1 > 1500:
16470  x1 = xright
16471  elif x1 < -500:
16472  x1 = xcenter - xright
16473  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())
16474  else:
16475  if ShowPB_A.get() > 0:
16476  if CMAphase > 180:
16477  CMAphase = CMAphase - 360
16478  elif CMAphase < -180:
16479  CMAphase = CMAphase + 360
16480  MagRadius = PeakVMA / VoltsperPixel
16481  y1 = ycenter - MagRadius*math.sin(math.radians(CMAphase))
16482  if y1 > 1500:
16483  y1 = xright
16484  elif y1 < -500:
16485  y1 = ycenter - xright
16486  x1 = xcenter + MagRadius*math.cos(math.radians(CMAphase))
16487  if x1 > 1500:
16488  x1 = xright
16489  elif x1 < -500:
16490  x1 = xcenter - xright
16491  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace2, arrow="last", width=TRACEwidth.get())#
16492  if ShowPB_B.get() > 0:
16493  if CMBphase > 180:
16494  CMBphase = CMBphase - 360
16495  elif CMBphase < -180:
16496  CMBphase = CMBphase + 360
16497  MagRadius = PeakVMB / VoltsperPixel
16498  y1 = ycenter - MagRadius*math.sin(math.radians(CMBphase))
16499  if y1 > 1500:
16500  y1 = xright
16501  elif y1 < -500:
16502  y1 = ycenter - xright
16503  x1 = xcenter + MagRadius*math.cos(math.radians(CMBphase))
16504  if x1 > 1500:
16505  x1 = xright
16506  elif x1 < -500:
16507  x1 = xcenter - xright
16508  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace6, arrow="last", width=TRACEwidth.get())#
16509  if ShowPB_C.get() > 0:
16510  if CMCphase > 180:
16511  CMCphase = CMCphase - 360
16512  elif CMCphase < -180:
16513  CMCphase = CMCphase + 360
16514  MagRadius = PeakVMC / VoltsperPixel
16515  y1 = ycenter - MagRadius*math.sin(math.radians(CMCphase))
16516  if y1 > 1500:
16517  y1 = xright
16518  elif y1 < -500:
16519  y1 = ycenter - xright
16520  x1 = xcenter + MagRadius*math.cos(math.radians(CMCphase))
16521  if x1 > 1500:
16522  x1 = xright
16523  elif x1 < -500:
16524  x1 = xcenter - xright
16525  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace7, arrow="last", width=TRACEwidth.get())#
16526  if ShowPB_D.get() > 0:
16527  if CMDphase > 180:
16528  CMDphase = CMDphase - 360
16529  elif CMDphase < -180:
16530  CMDphase = CMDphase + 360
16531  MagRadius = PeakVMD / VoltsperPixel
16532  y1 = ycenter - MagRadius*math.sin(math.radians(CMDphase))
16533  if y1 > 1500:
16534  y1 = xright
16535  elif y1 < -500:
16536  y1 = ycenter - xright
16537  x1 = xcenter + MagRadius*math.cos(math.radians(CMDphase))
16538  if x1 > 1500:
16539  x1 = xright
16540  elif x1 < -500:
16541  x1 = xcenter - xright
16542  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())#
16543  if iat_btn.config('text')[-1] == 'ON':
16544  MagRadius = PeakIA / mAperPixel
16545  y1 = ycenter - MagRadius*math.sin(math.radians(CAIphase))
16546  if y1 > 1500:
16547  y1 = xright
16548  elif y1 < -500:
16549  y1 = ycenter - xright
16550  x1 = xcenter + MagRadius*math.cos(math.radians(CAIphase))
16551  if x1 > 1500:
16552  x1 = xright
16553  elif x1 < -500:
16554  x1 = xcenter - xright
16555  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace3, arrow="last", width=TRACEwidth.get())
16556  if ibt_btn.config('text')[-1] == 'ON':
16557  MagRadius = PeakIB / mAperPixel
16558  y1 = ycenter - MagRadius*math.sin(math.radians(CBIphase))
16559  if y1 > 1500:
16560  y1 = xright
16561  elif y1 < -500:
16562  y1 = ycenter - xright
16563  x1 = xcenter + MagRadius*math.cos(math.radians(CBIphase))
16564  if x1 > 1500:
16565  x1 = xright
16566  elif x1 < -500:
16567  x1 = xcenter - xright
16568  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace4, arrow="last", width=TRACEwidth.get())
16569  if MuxScreenStatus.get() == 0:
16570  if vabt_btn.config('text')[-1] == 'ON':
16571  MagRadius = PeakVAB / VoltsperPixel
16572 
16573  y1 = ycenter - MagRadius*math.sin(math.radians(CABVphase))
16574  if y1 > 1500:
16575  y1 = xright
16576  elif y1 < -500:
16577  y1 = ycenter - xright
16578  x1 = xcenter + MagRadius*math.cos(math.radians(CABVphase))
16579  if x1 > 1500:
16580  x1 = xright
16581  elif x1 < -500:
16582  x1 = xcenter - xright
16583  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
16584 # display warning if input out of range
16585  if OverRangeFlagA == 1:
16586  x = X0LPhA+GRWPhA+10
16587  y = Y0TPhA+GRHPhA-40
16588  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
16589  PhAca.create_text (x+12, y, text="CHA Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
16590  if OverRangeFlagB == 1:
16591  x = X0LPhA+GRWPhA+10
16592  y = Y0TPhA+GRHPhA-10
16593  PhAca.create_rectangle(x-6, y-6, x+6, y+6, fill="#ff0000")
16594  PhAca.create_text (x+12, y, text="CHB Over Range", anchor=W, fill="#ff0000", font=("arial", FontSize+4 ))
16595 # General information on top of the grid
16596  txt = " Sample rate: " + str(SAMPLErate)
16597  txt = txt + " FFT samples: " + str(SMPfft)
16598  txt = txt + " " + FFTwindowname
16599 
16600  x = X0LPhA
16601  y = 12
16602  idTXT = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
16603  #
16604  x = X0LPhA + GRWPhA + 4
16605  y = 24
16606  if ChopMuxMode.get() == 0:
16607  txt = "CA " + ' {0:.3f} '.format(PeakVA) + " RMS V"
16608  TXT9 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
16609  y = y + 24
16610  if MuxScreenStatus.get() == 0:
16611  txt = "CB " + ' {0:.3f} '.format(PeakVB) + " RMS V"
16612  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16613  y = y + 24
16614  else:
16615  if ShowPB_A.get() > 0:
16616  txt = "Mux A " + ' {0:.3f} '.format(PeakVMA) + " RMS V"
16617  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16618  y = y + 24
16619  if ShowPB_B.get() > 0:
16620  txt = "Mux B " + ' {0:.3f} '.format(PeakVMB) + " RMS V"
16621  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
16622  y = y + 24
16623  if ShowPB_C.get() > 0:
16624  txt = "Mux C " + ' {0:.3f} '.format(PeakVMC) + " RMS V"
16625  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
16626  y = y + 24
16627  if ShowPB_D.get() > 0:
16628  txt = "Mux D " + ' {0:.3f} '.format(PeakVMD) + " RMS V"
16629  TXT10 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16630  y = y + 24
16631  if iat_btn.config('text')[-1] == 'ON':
16632  txt = "CA " + ' {0:.2f} '.format(PeakIA) + " RMS mA"
16633  TXT11 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
16634  y = y + 24
16635  if ibt_btn.config('text')[-1] == 'ON':
16636  txt = "CB " + ' {0:.2f} '.format(PeakIB) + " RMS mA"
16637  TXT12 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16638  y = y + 24
16639  if ChopMuxMode.get() == 0:
16640  txt = "CA V Phase " + ' {0:.1f} '.format(CAVphase) + " Degrees"
16641  TXT13 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace1, font=("arial", FontSize+4 ))
16642  y = y + 24
16643  if MuxScreenStatus.get() == 0:
16644  txt = "CB V Phase " + ' {0:.1f} '.format(CBVphase) + " Degrees"
16645  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16646  y = y + 24
16647  else:
16648  if ShowPB_A.get() > 0:
16649  txt = "Mux A Phase " + ' {0:.1f} '.format(CMAphase) + " Degrees"
16650  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace2, font=("arial", FontSize+4 ))
16651  y = y + 24
16652  if ShowPB_B.get() > 0:
16653  txt = "Mux B Phase " + ' {0:.1f} '.format(CMBphase) + " Degrees"
16654  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace6, font=("arial", FontSize+4 ))
16655  y = y + 24
16656  if ShowPB_C.get() > 0:
16657  txt = "Mux C Phase " + ' {0:.1f} '.format(CMCphase) + " Degrees"
16658  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace7, font=("arial", FontSize+4 ))
16659  y = y + 24
16660  if ShowPB_D.get() > 0:
16661  txt = "Mux D Phase " + ' {0:.1f} '.format(CMDphase) + " Degrees"
16662  TXT14 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16663  y = y + 24
16664  if iat_btn.config('text')[-1] == 'ON':
16665  txt = "CA I Phase " + ' {0:.1f} '.format(CAIphase) + " Degrees"
16666  TXT15 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace3, font=("arial", FontSize+4 ))
16667  y = y + 24
16668  if ibt_btn.config('text')[-1] == 'ON':
16669  txt = "CB I Phase " + ' {0:.1f} '.format(CBIphase) + " Degrees"
16670  TXT16 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtrace4, font=("arial", FontSize+4 ))
16671  y = y + 24
16672  #
16673  if ChopMuxMode.get() == 0:
16674  txt = "CA-V Freq " + ' {0:.1f} '.format(PeakfreqVA) + " Hertz"
16675  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16676  y = y + 24
16677  else:
16678  txt = "Mux A Freq " + ' {0:.1f} '.format(PeakfreqVMA) + " Hertz"
16679  TXT17 = PhAca.create_text (x, y, text=txt, anchor=W, fill=COLORtext, font=("arial", FontSize+4 ))
16680  y = y + 24
16681 #
16682  txt = " "
16683 # print time domin measured period and frequency of displayed channels
16684  if ShowC1_V.get() == 1 or ShowC2_V.get() == 1:
16685  if ETSDisp.get() > 0:
16686  FindRisingEdge(VBuffA[:int(DISsamples)],VBuffB[:int(DISsamples)])
16687  else:
16688  FindRisingEdge(VBuffA,VBuffB)
16689  if ShowC1_V.get() == 1:
16690  if MeasAHW.get() == 1:
16691  txt = txt + " CA Hi Width = " + ' {0:.3f} '.format(CHAHW/Mulx) + " mS "
16692  if MeasALW.get() == 1:
16693  txt = txt + " CA Lo Width = " + ' {0:.3f} '.format(CHALW/Mulx) + " mS "
16694  if MeasADCy.get() == 1:
16695  txt = txt + " CA DutyCycle = " + ' {0:.1f} '.format(CHADCy) + " % "
16696  if MeasAPER.get() == 1:
16697  txt = txt + " CA Period = " + ' {0:.3f} '.format(CHAperiod/Mulx) + " mS "
16698  if MeasAFREQ.get() == 1:
16699  txt = txt + " CA Freq = "
16700  ChaF = float(CHAfreq*Mulx)
16701  if ChaF < 1000:
16702  V1String = ' {0:.2f} '.format(ChaF)
16703  txt = txt + str(V1String) + " Hz "
16704  if ChaF > 1000 and ChaF < 1000000:
16705  V1String = ' {0:.2f} '.format(ChaF/1000)
16706  txt = txt + str(V1String) + " KHz "
16707  if ChaF > 1000000:
16708  V1String = ' {0:.2f} '.format(ChaF/1000000)
16709  txt = txt + str(V1String) + " MHz "
16710  #txt = txt + " CA Freq = " + ' {0:.1f} '.format(CHAfreq) + " Hz "
16711  if ShowC2_V.get() == 1:
16712  if MeasBHW.get() == 1:
16713  txt = txt + " CB Hi Width = " + ' {0:.3f} '.format(CHBHW/Mulx) + " mS "
16714  if MeasBLW.get() == 1:
16715  txt = txt + " CB Lo Width = " + ' {0:.3f} '.format(CHBLW/Mulx) + " mS "
16716  if MeasBDCy.get() == 1:
16717  txt = txt + " CB DutyCycle = " + ' {0:.1f} '.format(CHBDCy) + " % "
16718  if MeasBPER.get() == 1:
16719  txt = txt + " CB Period = " + ' {0:.3f} '.format(CHBperiod/Mulx) + " mS "
16720  if MeasBFREQ.get() == 1:
16721  txt = txt + " CB Freq = "
16722  ChaF = float(CHBfreq*Mulx)
16723  if ChaF < 1000:
16724  V1String = ' {0:.2f} '.format(ChaF)
16725  txt = txt + str(V1String) + " Hz "
16726  if ChaF > 1000 and ChaF < 1000000:
16727  V1String = ' {0:.2f} '.format(ChaF/1000)
16728  txt = txt + str(V1String) + " KHz "
16729  if ChaF > 1000000:
16730  V1String = ' {0:.2f} '.format(ChaF/1000000)
16731  txt = txt + str(V1String) + " MHz "
16732  #txt = txt + " CB Freq = " + ' {0:.1f} '.format(CHBfreq) + " Hz "
16733  if MuxScreenStatus.get() == 0:
16734  if MeasPhase.get() == 1:
16735  txt = txt + " CA-B Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
16736  if MeasDelay.get() == 1:
16737  txt = txt + " CB-A Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
16738 
16739  x = X0LPhA
16740  y = YBot + int(2.5 *FontSize) #
16741  TXT18 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16742  txt = " "
16743  if ShowC1_V.get() == 1:
16744  # Channel A information
16745  if CHA_RC_HP.get() == 1:
16746  txt = "CHA: HP "
16747  else:
16748  txt = "CHA: "
16749  if MeasDCV1.get() == 1:
16750  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV1)
16751  if MeasMaxV1.get() == 1:
16752  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV1)
16753  if MeasTopV1.get() == 1:
16754  txt = txt + " Top = " + ' {0:.4f} '.format(VATop)
16755  if MeasMinV1.get() == 1:
16756  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV1)
16757  if MeasBaseV1.get() == 1:
16758  txt = txt + " Base = " + ' {0:.4f} '.format(VABase)
16759  if MeasMidV1.get() == 1:
16760  MidV1 = (MaxV1+MinV1)/2.0
16761  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV1)
16762  if MeasPPV1.get() == 1:
16763  PPV1 = MaxV1-MinV1
16764  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV1)
16765  if MeasRMSV1.get() == 1:
16766  txt = txt + " RMS = " + ' {0:.4f} '.format(SV1)
16767  if MeasRMSVA_B.get() == 1:
16768  txt = txt + " A-B RMS = " + ' {0:.4f} '.format(SVA_B)
16769  if MeasDiffAB.get() == 1:
16770  txt = txt + " CA-CB = " + ' {0:.4f} '.format(DCV1-DCV2)
16771  if MeasUserA.get() == 1:
16772  try:
16773  TempValue = eval(UserAString)
16774  V1String = ' {0:.4f} '.format(TempValue)
16775  except:
16776  V1String = "####"
16777  txt = txt + UserALabel + " = " + V1String
16778  if (ShowC1_I.get() == 1 and ShowC1_V.get() == 0):
16779  txt = "CHA: "
16780  elif (ShowC1_I.get() == 1 and ShowC1_V.get() == 1):
16781  txt = txt + "CHA: "
16782 
16783  if ShowC1_I.get() == 1:
16784  if MeasDCI1.get() == 1:
16785  V1String = ' {0:.2f} '.format(DCI1)
16786  txt = txt + " AvgI = " + V1String
16787  if AWGAShape.get() == 0: # if this is a DC measurement calc resistance
16788  try:
16789  Resvalue = (DCV1/DCI1)*1000
16790  txt = txt + " Res = " + ' {0:.1f} '.format(Resvalue)
16791  except:
16792  txt = txt + " Res = OverRange"
16793  if MeasMaxI1.get() == 1:
16794  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI1)
16795  if MeasMinI1.get() == 1:
16796  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI1)
16797  if MeasMidI1.get() == 1:
16798  MidI1 = (MaxI1+MinI1)/2.0
16799  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI1)
16800  if MeasPPI1.get() == 1:
16801  PPI1 = MaxI1-MinI1
16802  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI1)
16803  if MeasRMSI1.get() == 1:
16804  txt = txt + " RMS = " + ' {0:.4f} '.format(SI1)
16805 
16806  x = X0LPhA
16807  y = YBot + int(4*FontSize) #
16808  TXT19 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16809  txt= " "
16810  # Channel B information
16811  if MuxScreenStatus.get() == 1:
16812  txt = "CHB-Mux: "
16813  if Show_CBA.get() > 0:
16814  FindRisingEdge(VBuffA,VBuffMA)
16815  elif Show_CBB.get() > 0:
16816  FindRisingEdge(VBuffA,VBuffMB)
16817  elif Show_CBC.get() > 0:
16818  FindRisingEdge(VBuffA,VBuffMC)
16819  elif Show_CBD.get() > 0:
16820  FindRisingEdge(VBuffA,VBuffMD)
16821  if MeasPhase.get() == 1:
16822  txt = txt + " CA-Mux Phase = " + ' {0:.1f} '.format(CHABphase) + " deg "
16823  if MeasDelay.get() == 1:
16824  txt = txt + " Mux-CA Delay = " + ' {0:.3f} '.format(CHBADelayR1) + " mS "
16825  if MeasUserB.get() == 1:
16826  try:
16827  TempValue = eval(UserBString)
16828  V1String = ' {0:.4f} '.format(TempValue)
16829  except:
16830  V1String = "####"
16831  txt = txt + UserBLabel + " = " + V1String
16832  if ShowC2_V.get() == 1:
16833  if CHB_RC_HP.get() == 1:
16834  txt = "CHB: HP "
16835  else:
16836  txt = "CHB: "
16837  if MeasDCV2.get() == 1:
16838  txt = txt + " AvgV = " + ' {0:.4f} '.format(DCV2)
16839  if MeasMaxV2.get() == 1:
16840  txt = txt + " MaxV = " + ' {0:.4f} '.format(MaxV2)
16841  if MeasTopV2.get() == 1:
16842  txt = txt + " Top = " + ' {0:.4f} '.format(VBTop)
16843  if MeasMinV2.get() == 1:
16844  txt = txt + " MinV = " + ' {0:.4f} '.format(MinV2)
16845  if MeasBaseV2.get() == 1:
16846  txt = txt + " Base = " + ' {0:.4f} '.format(VBBase)
16847  if MeasMidV2.get() == 1:
16848  MidV2 = (MaxV2+MinV2)/2.0
16849  txt = txt + " MidV = " + ' {0:.4f} '.format(MidV2)
16850  if MeasPPV2.get() == 1:
16851  PPV2 = MaxV2-MinV2
16852  txt = txt + " P-PV = " + ' {0:.4f} '.format(PPV2)
16853  if MeasRMSV2.get() == 1:
16854  txt = txt + " RMS = " + ' {0:.4f} '.format(SV2)
16855  if MeasDiffBA.get() == 1:
16856  txt = txt + " CB-CA = " + ' {0:.4f} '.format(DCV2-DCV1)
16857  if MeasUserB.get() == 1:
16858  try:
16859  TempValue = eval(UserBString)
16860  V1String = ' {0:.4f} '.format(TempValue)
16861  except:
16862  V1String = "####"
16863  txt = txt + UserBLabel + " = " + V1String
16864  if (ShowC2_I.get() == 1 and ShowC2_V.get() == 0):
16865  txt = "CHB: "
16866  elif (ShowC2_I.get() == 1 and ShowC2_V.get() == 1):
16867  txt = txt + "CHB: "
16868  if ShowC2_I.get() == 1:
16869  if MeasDCI2.get() == 1:
16870  V1String = ' {0:.2f} '.format(DCI2)
16871  txt = txt + " AvgI = " + V1String
16872  if AWGBShape.get() == 0: # if this is a DC measurement calc resistance
16873  try:
16874  Resvalue = (DCV2/DCI2)*1000
16875  R1String = ' {0:.1f} '.format(Resvalue)
16876  txt = txt + " Res = " + R1String
16877  except:
16878  txt = txt + " Res = OverRange"
16879  if MeasMaxI2.get() == 1:
16880  txt = txt + " MaxI = " + ' {0:.2f} '.format(MaxI2)
16881  if MeasMinI2.get() == 1:
16882  txt = txt + " MinI = " + ' {0:.2f} '.format(MinI2)
16883  if MeasMidI2.get() == 1:
16884  MidI2 = (MaxI2+MinI2)/2.0
16885  txt = txt + " MidV = " + ' {0:.2f} '.format(MidI2)
16886  if MeasPPI2.get() == 1:
16887  PPI2 = MaxI2-MinI2
16888  txt = txt + " P-PI = " + ' {0:.2f} '.format(PPI2)
16889  if MeasRMSI2.get() == 1:
16890  txt = txt + " RMS = " + ' {0:.4f} '.format(SI2)
16891 
16892  x = X0LPhA
16893  y = YBot + int(5.5 *FontSize) #
16894  TXT20 = PhAca.create_text(x, y, text=txt, anchor=W, fill=COLORtext)
16895 #
16897  global PeakVA, PeakVB, PeakIA, PeakIB
16898  global PeakfreqVA, PeakfreqVB, PeakfreqIA, PeakfreqIB
16899  global PeakVMA, PeakVMB, PeakVMC, PeakVMD
16900  global CAVphase, CBVphase, CAIphase, CBIphase, CABVphase
16901  global CMAphase, CMBphase, CMCphase, CMDphase
16902  global MuxScreenStatus, AppendPhAData, PhADatafilename
16903  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn
16904  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D
16905 
16906  # open file to save data
16907  if AppendPhAData.get() == 0:
16908  PhADatafilename = asksaveasfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
16909  DataFile = open(PhADatafilename, 'a')
16910  DataFile.write( 'Amplitude, Phase, @ ' + str(PeakfreqVA) + ' Hertz\n')
16911 
16912  if vat_btn.config('text')[-1] == 'ON':
16913  DataFile.write( str(PeakVA) + ', ' + str(CAVphase) + ', CA-V\n')
16914  if MuxScreenStatus.get() == 0:
16915  if vbt_btn.config('text')[-1] == 'ON':
16916  DataFile.write( str(PeakVB) + ', ' + str(CBVphase) + ', CB-V\n')
16917  else:
16918  if ShowPB_A.get() > 0:
16919  DataFile.write( str(PeakVMA) + ', ' + str(CMAphase) + ', Mux A\n')
16920  if ShowPB_B.get() > 0:
16921  DataFile.write( str(PeakVMB) + ', ' + str(CMBphase) + ', Mux B\n')
16922  if ShowPB_C.get() > 0:
16923  DataFile.write( str(PeakVMC) + ', ' + str(CMCphase) + ', Mux C\n')
16924  if ShowPB_D.get() > 0:
16925  DataFile.write( str(PeakVMD) + ', ' + str(CMDphase) + ', Mux D\n')
16926  if iat_btn.config('text')[-1] == 'ON':
16927  DataFile.write( str(PeakIA) + ', ' + str(CAIphase) + ', CA-I\n')
16928  if ibt_btn.config('text')[-1] == 'ON':
16929  DataFile.write( str(PeakIB) + ', ' + str(CBIphase) + ', CB-I\n')
16930  DataFile.close()
16931 #
16933  global CANVASheightPhA, CANVASwidthPhA, PhAca, TRACEwidth, GridWidth, PhAPlotMode
16934  global COLORsignalband, COLORtext, COLORgrid, SmoothCurves # The colors
16935  global COLORtrace1, COLORtrace2, COLORtrace3, COLORtrace4, COLORtrace5, COLORtrace6, COLORtrace7
16936  global GRWPhA, GRHPhA, X0LPhA, Vdiv, VScale, IScale
16937 # open file to read data from
16938  filename = askopenfilename(defaultextension = ".csv", filetypes=[("Comma Separated Values", "*.csv")])
16939  i = 1
16940  xcenter = GRWPhA/2
16941  ycenter = (GRHPhA/2) + 14
16942  Radius = (GRWPhA-X0LPhA)/(1 + Vdiv.get()*2) # 11
16943  VoltsperPixel = float(VScale.get())/Radius
16944  mAperPixel = float(IScale.get())/Radius
16945  TRadius = Radius * Vdiv.get() # 5
16946  x1 = X0LPhA
16947  x2 = X0LPhA + GRWPhA
16948  PhATrace = []
16949 # Read values from CVS file
16950  try:
16951  CSVFile = open(filename)
16952  dialect = csv.Sniffer().sniff(CSVFile.read(2048))
16953  CSVFile.seek(0)
16954  csv_f = csv.reader(CSVFile, dialect)
16955  for row in csv_f:
16956  try:
16957  PeakMag = float(row[0])
16958  PeakPhase = float(row[1])
16959  if row[2] == "CA-I" or row[2] == "CB-I":
16960  MagRadius = PeakMag / mAperPixel
16961  else:
16962  MagRadius = PeakMag / VoltsperPixel
16963 
16964  y1 = ycenter - MagRadius*math.sin(math.radians(PeakPhase))
16965  if y1 > 1500:
16966  y1 = xright
16967  elif y1 < -500:
16968  y1 = ycenter - xright
16969  x1 = xcenter + MagRadius*math.cos(math.radians(PeakPhase))
16970  if x1 > 1500:
16971  x1 = xright
16972  elif x1 < -500:
16973  x1 = xcenter - xright
16974  if PhAPlotMode.get() == 0:
16975  PhAca.create_line(xcenter, ycenter, x1, y1, fill=COLORtrace5, arrow="last", width=TRACEwidth.get())
16976  else:
16977  PhATrace.append(x1)
16978  PhATrace.append(y1)
16979  except:
16980  print( 'skipping non-numeric row')
16981  if PhAPlotMode.get() == 1:
16982  PhAca.create_line(PhATrace, fill=COLORtrace5, smooth=SmoothCurves.get(), splinestep=5, width=TRACEwidth.get())
16983  CSVFile.close()
16984  except:
16985  showwarning("WARNING","No such file found or wrong format!")
16986 #
16987 #
16988 def STOREcsvfile(): # Store the trace as CSV file [frequency, magnitude or dB value]
16989  global FFTmemoryA, FFTresultA, SMPfft
16990  global FFTmemoryB, FFTresultB
16991  global PhaseA, PhaseB, freqwindow
16992  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, ShowC1_VdB, ShowC2_VdB
16993 
16994  # Set the TRACEsize variable
16995  if ShowC1_VdB.get() == 1:
16996  TRACEsize = len(FFTresultA) # Set the trace length
16997  elif ShowC2_VdB.get() == 1:
16998  TRACEsize = len(FFTresultB)
16999  if TRACEsize == 0: # If no trace, skip rest of this routine
17000  return()
17001 # ask if save as magnitude or dB
17002  dB = askyesno("Mag or dB: ","Save amplidude data as dB (Yes) or Mag (No):\n", parent=freqwindow)
17003  # Make the file name and open it
17004  if dB == 0:
17005  PSD = askyesno("Mag/Root Hz? ","Save Mag in V/sqrt Hz? (yes) or (No):\n", parent=freqwindow)
17006  tme = strftime("%Y%b%d-%H%M%S", gmtime()) # The time
17007  filename = "Spectrum-" + tme
17008  filename = filename + ".csv"
17009  # open file to save data
17010  filename = asksaveasfilename(initialfile = filename, defaultextension = ".csv",
17011  filetypes=[("Comma Separated Values", "*.csv")], parent=freqwindow)
17012  DataFile = open(filename,'a') # Open output file
17013  HeaderString = 'Frequency-#, '
17014  if ShowC1_VdB.get() == 1:
17015  if dB == 1:
17016  HeaderString = HeaderString + 'CA-dB, '
17017  if dB == 0:
17018  HeaderString = HeaderString + 'CA-Mag, '
17019  if ShowC2_VdB.get() == 1:
17020  if dB == 1:
17021  HeaderString = HeaderString + 'CB-dB, '
17022  if dB == 0:
17023  HeaderString = HeaderString + 'CB-Mag, '
17024  if ShowC1_P.get() == 1:
17025  HeaderString = HeaderString + 'Phase A-B, '
17026  if ShowC2_P.get() == 1:
17027  HeaderString = HeaderString + 'Phase B-A, '
17028  HeaderString = HeaderString + '\n'
17029  DataFile.write( HeaderString )
17030 
17031  FBinWidth = float(SAMPLErate / 2.0) / (TRACEsize - 1) # Frequency step per sample
17032  n = 0
17033 
17034  while n < TRACEsize:
17035  F = n * FBinWidth
17036  txt = str(F)
17037  if ShowC1_VdB.get() == 1:
17038  V = 10 * math.log10(float(FFTresultA[n])) #
17039  if dB == 0:
17040  V = 10.0**(V/20.0) # RMS Volts
17041  if PSD == 1:
17042  V = V/math.sqrt(FBinWidth) # per root Hz
17043  txt = txt + "," + str(V)
17044  if ShowC2_VdB.get() == 1:
17045  V = 10 * math.log10(float(FFTresultB[n])) #
17046  if dB == 0:
17047  V = 10.0**(V/20.0)# RMS Volts
17048  if PSD == 1:
17049  V = V/math.sqrt(FBinWidth) # per root Hz
17050  txt = txt + "," + str(V)
17051  if ShowC1_P.get() == 1:
17052  RelPhase = PhaseA[n]-PhaseB[n]
17053  if RelPhase > 180:
17054  RelPhase = RelPhase - 360
17055  elif RelPhase < -180:
17056  RelPhase = RelPhase + 360
17057  txt = txt + "," + str(RelPhase)
17058  if ShowC2_P.get() == 1:
17059  RelPhase = PhaseB[n]-PhaseA[n]
17060  if RelPhase > 180:
17061  RelPhase = RelPhase - 360
17062  elif RelPhase < -180:
17063  RelPhase = RelPhase + 360
17064  txt = txt + "," + str(RelPhase)
17065  txt = txt + "\n"
17066  DataFile.write(txt)
17067  n = n + 1
17068 
17069  DataFile.close() # Close the file
17070 
17072 def MakeFreqScreen(): # Update the screen with traces and text
17073  global CANVASheightF, CANVASwidthF, SmoothCurvesSA
17074  global PeakxA, PeakyA, PeakxB, PeakyB, PeakdbA, PeakdbB
17075  global PeakxM, PeakyM, PeakMdb, PeakfreqM
17076  global PeakfreqA, PeakfreqB, PeakfreqRA, PeakfreqRB
17077  global PeakxRA, PeakyRA, PeakxRB, PeakyRB, PeakdbRA, PeakdbRB
17078  global PeakxRM, PeakyRM, PeakRMdb, PeakfreqRM, PeakIndexA, PeakIndexB, Fsample
17079  global COLORgrid # The colors
17080  global COLORsignalband, COLORtext
17081  global COLORtrace1, COLORtrace2
17082  global FSweepMode, LoopNum, MarkerFreqNum, TRACEwidth, GridWidth
17083  global DBdivindex # Index value
17084  global DBdivlist # dB per division list
17085  global DBlevel # Reference level
17086  global FFTwindow, FFTbandwidth, ZEROstuffing, FFTwindowname
17087  global X0LF # Left top X value
17088  global Y0TF # Left top Y value
17089  global GRWF # Screenwidth
17090  global GRHF # Screenheight
17091  global FontSize
17092  global RUNstatus # 0 stopped, 1 start, 2 running, 3 stop now, 4 stop and restart
17093  global AWGSAMPLErate, SAMPLErate, BaseSampleRate, SingleShotSA, HScale, HarmonicMarkers
17094  global SMPfft # number of FFT samples
17095  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
17096  global StartFreqEntry, StopFreqEntry, PhCenFreqEntry, RelPhaseCenter
17097  global ShowC1_P, ShowC2_P, ShowRA_VdB, ShowRB_VdB, ShowMarker
17098  global ShowRA_P, ShowRB_P, ShowMathSA, FreqDisp, ShowAWGASA, ShowAWGBSA
17099  global ShowFCur, ShowdBCur, FCursor, dBCursor
17100  global T1Fline, T2Fline, T1Pline, T1FRline, T2FRline, TFMline, TFRMline
17101  global T1PRline, T2PRline, TAFline, TBFline
17102  global TRACEaverage # Number of traces for averageing
17103  global FreqTraceMode # 1 normal 2 max 3 average
17104  global Vdiv # Number of vertical divisions
17105 
17106  # Delete all items on the screen
17107  MarkerFreqNum = 0
17108  FBinWidth = float(SAMPLErate / 2.0) / (SMPfft - 1) # Frequency step per sample
17109  Freqca.delete(ALL) # remove all items
17110  try:
17111  StartFrequency = float(StartFreqEntry.get())
17112  except:
17113  StartFreqEntry.delete(0,"end")
17114  StartFreqEntry.insert(0,100)
17115  StartFrequency = 100
17116  try:
17117  StopFrequency = float(StopFreqEntry.get())
17118  except:
17119  StopFreqEntry.delete(0,"end")
17120  StopFreqEntry.insert(0,10000)
17121  StopFrequency = 10000
17122  try:
17123  Phasecenter = int(PhCenFreqEntry.get())
17124  RelPhaseCenter.set(Phasecenter)
17125  except:
17126  PhCenFreqEntry.delete(0,"end")
17127  PhCenFreqEntry.insert(0,0)
17128  RelPhaseCenter.set(0)
17129  Phasecenter = 0
17130  # Draw horizontal grid lines
17131  i = 0
17132  x1 = X0LF
17133  x2 = X0LF + GRWF
17134  if SAVScale.get() == 0: # In dB
17135  while (i <= Vdiv.get()):
17136  y = Y0TF + i * GRHF/Vdiv.get()
17137  Dline = [x1,y,x2,y]
17138  if i == 0 or i == Vdiv.get():
17139  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17140  else:
17141  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17142  Vaxis_value = (DBlevel.get() - (i * DBdivlist[DBdivindex.get()]))
17143  Vaxis_label = str(Vaxis_value)
17144  Freqca.create_text(x1-3, y, text=Vaxis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17145  if ShowC1_P.get() == 1 or ShowC2_P.get() == 1:
17146  Vaxis_value = ( 180 - ( i * (360 / Vdiv.get())))
17147  Vaxis_value = Vaxis_value + Phasecenter
17148  Vaxis_label = str(Vaxis_value)
17149  Freqca.create_text(x2+3, y, text=Vaxis_label, fill=COLORtrace3, anchor="w", font=("arial", FontSize ))
17150  i = i + 1
17151  else: # In rms V
17152  if SAVScale.get() == 2: # Log Scale
17153  try:
17154  LogVStop = math.log10(SAvertmax)
17155  except:
17156  LogVStop = 0.0
17157  try:
17158  LogVStart = math.log10(SAvertmin)
17159  except:
17160  LogVStart = -10
17161  LogVpixel = (LogVStart - LogVStop) / GRHF
17162  NumDec = LogVStart - LogVStop # number of major grids
17163  Gridpixel = GRHF/NumDec # number of pixels per major grid
17164  V = NumDec
17165  while V <= 0: # Major Grid lines
17166  try:
17167  LogV = math.log10(10**V) # convet to log Volts
17168  y = Y0TF + (LogV/LogVpixel)
17169  except:
17170  y = Y0TF
17171  Dline = [x1,y,x2,y]
17172  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17173  LNum = LogVStop + V
17174  if LNum == 1.0:
17175  axis_label = "10.0"
17176  elif LNum == 0:
17177  axis_label = "1.0"
17178  elif LNum == -1:
17179  axis_label = "100mV"
17180  elif LNum == -2:
17181  axis_label = "10mV"
17182  elif LNum == -3:
17183  axis_label = "1mV"
17184  elif LNum == -4:
17185  axis_label = "100uV"
17186  elif LNum == -5:
17187  axis_label = "10uV"
17188  elif LNum == -6:
17189  axis_label = "1uV"
17190  elif LNum == -7:
17191  axis_label = "100nV"
17192  elif LNum == -8:
17193  axis_label = "10nV"
17194  else:
17195  axis_label = str(LogVStart+V)
17196  print(LNum)
17197  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17198  J = 2
17199  while J < 10: # Minor Grid lines
17200  ym = y + (Gridpixel*math.log10(J))
17201  Dline = [x1,ym,x2,ym]
17202  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17203  J = J + 1
17204  V = V + 1
17205  else: # Linear Scale
17206  i = 0
17207  Vper = (SAvertmax - SAvertmin) / Vdiv.get()
17208  while (i < Vdiv.get()+1):
17209  y = Y0TF + i * GRHF/Vdiv.get()
17210  Dline = [x1,y,x2,y]
17211  if i == 0 or i == Vdiv.get():
17212  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17213  else:
17214  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17215  axis_value = (SAvertmax - (i * Vper))
17216  axis_label = ' {0:.3f} '.format(axis_value) # str(axis_value)
17217  Freqca.create_text(x1-3, y, text=axis_label, fill=COLORtrace1, anchor="e", font=("arial", FontSize ))
17218  i = i + 1
17219  # Draw vertical grid lines
17220  i = 0
17221  y1 = Y0TF
17222  y2 = Y0TF + GRHF
17223  if HScale.get() == 1:
17224  F = 1.0
17225  LogFStop = math.log10(StopFrequency)
17226  try:
17227  LogFStart = math.log10(StartFrequency)
17228  except:
17229  LogFStart = 0.0
17230  LogFpixel = (LogFStop - LogFStart) / GRWF
17231  # draw left and right edges
17232  while F <= StopFrequency:
17233  if F >= StartFrequency:
17234  try:
17235  LogF = math.log10(F) # convet to log Freq
17236  x = X0LF + (LogF - LogFStart)/LogFpixel
17237  except:
17238  x = X0LF
17239  Dline = [x,y1,x,y2]
17240  if F == 1 or F == 10 or F == 100 or F == 1000 or F == 10000 or F == 100000:
17241  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17242  axis_label = str(F)
17243  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
17244  else:
17245  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17246 
17247  if F < 10:
17248  F = F + 1
17249  elif F < 100:
17250  F = F + 10
17251  elif F < 1000:
17252  F = F + 100
17253  elif F < 1000:
17254  F = F + 100
17255  elif F < 10000:
17256  F = F + 1000
17257  elif F < 100000:
17258  F = F + 10000
17259  elif F < 200000:
17260  F = F + 10000
17261  else:
17262  Freqdiv = (StopFrequency - StartFrequency) / 10
17263  while (i < 11):
17264  x = X0LF + i * GRWF/10.0
17265  Dline = [x,y1,x,y2]
17266  if i == 0 or i == 10:
17267  Freqca.create_line(Dline, fill=COLORgrid, width=GridWidth.get())
17268  else:
17269  Freqca.create_line(Dline, dash=(4,3), fill=COLORgrid, width=GridWidth.get())
17270  axis_value = (StartFrequency + (i * Freqdiv))
17271  axis_label = str(axis_value)
17272  Freqca.create_text(x, y2+3, text=axis_label, fill=COLORgrid, anchor="n", font=("arial", FontSize ))
17273  i = i + 1
17274  # Draw X - Y cursors if needed
17275  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
17276  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
17277  # Vertical conversion factors (level dBs) and border limits
17278  YVconv = float(GRHF) / (SAvertmax - SAvertmin) #
17279  YVc = float(Y0TF) + YVconv * SAvertmax
17280  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17281  if ShowFCur.get() > 0:
17282  Dline = [FCursor, Y0TF, FCursor, Y0TF+GRHF]
17283  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
17284  # Horizontal conversion factors (frequency Hz) and border limits
17285  if HScale.get() == 1:
17286  LogFStop = math.log10(StopFrequency)
17287  try:
17288  LogFStart = math.log10(StartFrequency)
17289  except:
17290  LogFStart = 0.0
17291  LogFpixel = (LogFStop - LogFStart) / GRWF
17292  xfreq = 10**(((FCursor-X0LF)*LogFpixel) + LogFStart)
17293  else:
17294  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17295  xfreq = ((FCursor-X0LF)*Fpixel)+StartFrequency
17296  XFString = ' {0:.2f} '.format(xfreq)
17297  V_label = XFString + " Hz"
17298  Freqca.create_text(FCursor+1, Y0TF+GRHF+6, text=V_label, fill=COLORtext, anchor="n", font=("arial", FontSize ))
17299  #Freqca.create_text(FCursor+1, dBCursor-5, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
17300 #
17301  if ShowdBCur.get() > 0:
17302  Dline = [X0LF, dBCursor, X0LF+GRWF, dBCursor]
17303  Freqca.create_line(Dline, dash=(3,4), fill=COLORtrigger, width=GridWidth.get())
17304  if SAVScale.get() == 0: # In dB
17305  yvdB = ((Yc-dBCursor)/Yconv)
17306  VdBString = ' {0:.1f} '.format(yvdB)
17307  V_label = VdBString + " dBV"
17308  elif SAVScale.get() == 1: # Lin Scale
17309  yvdB = ((YVc-dBCursor)/YVconv)
17310  VdBString = ' {0:.3f} '.format(yvdB)
17311  V_label = VdBString + " Vrms"
17312  else: # Log Scale
17313  LogVpixel = (LogVStop - LogVStart) / GRHF
17314  Vlog = ((YVc - dBCursor) * LogVpixel) + LogVStart
17315  yvdB = 10**Vlog
17316  VdBString = ' {:.2e} '.format(yvdB)
17317  V_label = VdBString + " Vrms"
17318 
17319  Freqca.create_text(X0LF+GRWF-5, dBCursor, text=V_label, fill=COLORtext, anchor="w", font=("arial", FontSize ))
17320  #
17321  SmoothBool = SmoothCurvesSA.get()
17322  # Draw traces
17323  if len(T1Fline) > 4: # Avoid writing lines with 1 coordinate
17324  # Write the trace CHA
17325  if OverRangeFlagA == 1:
17326  Freqca.create_line(T1Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17327  else:
17328  Freqca.create_line(T1Fline, fill=COLORtrace1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17329  if ShowMarker.get() > 0:
17330  k = 1
17331  while k <= HarmonicMarkers.get():
17332  FreqA = k*PeakIndexA*Fsample
17333  #
17334  if SAVScale.get() == 0: # In dB
17335  if SAVPSD.get() == 1:
17336  try:
17337  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])/math.sqrt(FBinWidth))
17338  except:
17339  dbA = -100
17340  else:
17341  try:
17342  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k]))
17343  except:
17344  dbA = -100
17345  if ShowMarker.get() == 2 and k > 1:
17346  Peak_label = ' {0:.2f} '.format(dbA - PeakdbA) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17347  else:
17348  Peak_label = ' {0:.2f} '.format(dbA) + ',' + ' {0:.1f} '.format(FreqA)
17349  yA = Yc - Yconv * dbA
17350  else: # Volts Scale
17351  try:
17352  dbA = 10 * math.log10(float(FFTresultA[PeakIndexA*k])) # Convert power to DBs
17353  except:
17354  dbA = -100
17355  V = 10.0**(dbA/20.0)# convert back to RMS Volts
17356  PeakV = 10.0**(PeakdbA/20.0)# convert back to RMS Volts
17357  if SAVPSD.get() == 1: # per root Hz
17358  V = V/math.sqrt(FBinWidth)
17359  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
17360  if SAVScale.get() == 2: # Log Scale
17361  LogVpixel = (LogVStop - LogVStart) / GRHF
17362  try:
17363  LogV = math.log10(V) # convet to log Volts
17364  yA = YVc - (LogV - LogVStart)/LogVpixel
17365  except:
17366  yA = YVc - YVconv * V
17367  if ShowMarker.get() == 2 and k > 1:
17368  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17369  else:
17370  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
17371  else: # Lin Scale
17372  if ShowMarker.get() == 2 and k > 1:
17373  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqA - PeakfreqA)
17374  else:
17375  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqA)
17376  yA = YVc - YVconv * V
17377  #
17378  if HScale.get() == 1:
17379  try:
17380  LogF = math.log10(FreqA) # convet to log Freq
17381  xA = X0LF + int((LogF - LogFStart)/LogFpixel)
17382  except:
17383  xA = X0LF
17384  else:
17385  xA = X0LF+int((FreqA - StartFrequency)/Fpixel)# +StartFrequency
17386 
17387  Freqca.create_text(xA, yA, text=Peak_label, fill=COLORtrace1, anchor="s", font=("arial", FontSize ))
17388  k = k + 1
17389 
17390  if len(T2Fline) > 4: # Avoid writing lines with 1 coordinate
17391  # Write the trace CHB
17392  if OverRangeFlagB == 1:
17393  Freqca.create_line(T2Fline, fill=COLORsignalband, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17394  else:
17395  Freqca.create_line(T2Fline, fill=COLORtrace2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17396  if ShowMarker.get() > 0:
17397  k = 1
17398  while k <= HarmonicMarkers.get():
17399  FreqB = k*PeakIndexB*Fsample
17400  #
17401  if SAVScale.get() == 0: # In dB
17402  if SAVPSD.get() == 1:
17403  try:
17404  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])/math.sqrt(FBinWidth))
17405  except:
17406  dbB = -100
17407  else:
17408  try:
17409  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k]))
17410  except:
17411  dbb = -100
17412  if ShowMarker.get() == 2 and k > 1:
17413  Peak_label = ' {0:.2f} '.format(dbB - PeakdbB) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17414  else:
17415  Peak_label = ' {0:.2f} '.format(dbB) + ',' + ' {0:.1f} '.format(FreqB)
17416  yB = Yc - Yconv * dbB
17417  else: # Volts Scale
17418  try:
17419  dbB = 10 * math.log10(float(FFTresultB[PeakIndexB*k])) # Convert power to DBs
17420  except:
17421  dbB = -100
17422  V = 10.0**(dbB/20.0)# convert back to RMS Volts
17423  PeakV = 10.0**(PeakdbB/20.0)# convert back to RMS Volts
17424  if SAVPSD.get() == 1: # per root Hz
17425  V = V/math.sqrt(FBinWidth)
17426  PeakV = PeakV/math.sqrt(FBinWidth) # per root Hz
17427  if SAVScale.get() == 2: # Log Scale
17428  LogVpixel = (LogVStop - LogVStart) / GRHF
17429  try:
17430  LogV = math.log10(V) # convet to log Volts
17431  yB = YVc - (LogV - LogVStart)/LogVpixel
17432  except:
17433  yB = YVc - YVconv * V
17434  if ShowMarker.get() == 2 and k > 1:
17435  Peak_label = ' {0:.2e} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17436  else:
17437  Peak_label = ' {0:.2e} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
17438  else: # Lin Scale
17439  if ShowMarker.get() == 2 and k > 1:
17440  Peak_label = ' {0:.2f} '.format(V - PeakV) + ',' + ' {0:.1f} '.format(FreqB - PeakfreqB)
17441  else:
17442  Peak_label = ' {0:.2f} '.format(V) + ',' + ' {0:.1f} '.format(FreqB)
17443  yB = YVc - YVconv * V
17444  #
17445  if HScale.get() == 1:
17446  try:
17447  LogF = math.log10(FreqB) # convet to log Freq
17448  xB = X0LF + int((LogF - LogFStart)/LogFpixel)
17449  except:
17450  xB = X0LF
17451  else:
17452  xB = X0LF+int((FreqB - StartFrequency)/Fpixel)# +StartFrequency
17453 
17454  Freqca.create_text(xB, yB, text=Peak_label, fill=COLORtrace2, anchor="s", font=("arial", FontSize ))
17455  k = k + 1
17456 #
17457  if len(T1Pline) > 4: # Avoid writing lines with 1 coordinate
17458  # Write the phase trace A-B
17459  Freqca.create_line(T1Pline, fill=COLORtrace3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17460  if len(T2Pline) > 4: # Avoid writing lines with 1 coordinate
17461  # Write the phase trace A-B
17462  Freqca.create_line(T2Pline, fill=COLORtrace4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17463  if ShowAWGASA.get() > 0 and len(TAFline) > 4: # Write the AWG trace A if active
17464  Freqca.create_line(TAFline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17465  if ShowAWGBSA.get() > 0 and len(TBFline) > 4: # Write the AWG trace B if active
17466  Freqca.create_line(TBFline, fill=COLORtrace7, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17467  if ShowRA_VdB.get() == 1 and len(T1FRline) > 4: # Write the ref trace A if active
17468  Freqca.create_line(T1FRline, fill=COLORtraceR1, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17469  if ShowMarker.get() == 1:
17470  Peak_label = ' {0:.2f} '.format(PeakdbRA) + ',' + ' {0:.1f} '.format(PeakfreqRA)
17471  Freqca.create_text(PeakxRA, PeakyRA, text=Peak_label, fill=COLORtraceR1, anchor="s", font=("arial", FontSize ))
17472  if ShowRB_VdB.get() == 1 and len(T2FRline) > 4: # Write the ref trace B if active
17473  Freqca.create_line(T2FRline, fill=COLORtraceR2, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17474  if ShowMarker.get() == 1:
17475  Peak_label = ' {0:.2f} '.format(PeakdbRB) + ',' + ' {0:.1f} '.format(PeakfreqRB)
17476  Freqca.create_text(PeakxRB, PeakyRB, text=Peak_label, fill=COLORtraceR2, anchor="s", font=("arial", FontSize ))
17477  if ShowRA_P.get() == 1 and len(T1PRline) > 4: # Write the ref trace A if active
17478  Freqca.create_line(T1PRline, fill=COLORtraceR3, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17479  if ShowRB_P.get() == 1 and len(T2PRline) > 4: # Write the ref trace A if active
17480  Freqca.create_line(T2PRline, fill=COLORtraceR4, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17481  if ShowMathSA.get() > 0 and len(TFMline) > 4: # Write the Math trace if active
17482  Freqca.create_line(TFMline, fill=COLORtrace5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17483  if ShowMarker.get() ==1:
17484  Peak_label = ' {0:.2f} '.format(PeakMdb) + ',' + ' {0:.1f} '.format(PeakfreqM)
17485  Freqca.create_text(PeakxM, PeakyM, text=Peak_label, fill=COLORtrace5, anchor="s", font=("arial", FontSize ))
17486  if ShowRMath.get() == 1 and len(TFRMline) > 4: # Write the ref math trace if active
17487  Freqca.create_line(TFRMline, fill=COLORtraceR5, smooth=SmoothBool, splinestep=5, width=TRACEwidth.get())
17488  if ShowMarker.get() ==1:
17489  Peak_label = ' {0:.2f} '.format(PeakRMdb) + ',' + ' {0:.1f} '.format(PeakfreqRM)
17490  Freqca.create_text(PeakxRM, PeakyRM, text=Peak_label, fill=COLORtraceR5, anchor="s", font=("arial", FontSize ))
17491  # General information on top of the grid
17492 
17493  txt = " Sample rate: " + str(SAMPLErate)
17494  txt = txt + " FFT samples: " + str(SMPfft)
17495 
17496  txt = txt + " " + FFTwindowname
17497 
17498  x = X0LF
17499  y = 12
17500  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17501 
17502  # Start and stop frequency and dB/div and trace mode
17503  txt = str(StartFrequency) + " to " + str(StopFrequency) + " Hz"
17504  txt = txt + " " + str(DBdivlist[DBdivindex.get()]) + " dB/div"
17505  txt = txt + " Level: " + str(DBlevel.get()) + " dB "
17506  if FFTwindow.get() < 7:
17507  txt = txt + " FFT Bandwidth =" + ' {0:.2f} '.format(FFTbandwidth)
17508  else:
17509  txt = txt + " FFT Bandwidth = ???"
17510 
17511  x = X0LF
17512  y = Y0TF+GRHF+23
17513  idTXT = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17514 
17515  if FreqTraceMode.get() == 1:
17516  txt ="Normal mode "
17517 
17518  if FreqTraceMode.get() == 2:
17519  txt = "Peak hold mode "
17520 
17521  if FreqTraceMode.get() == 3:
17522  txt = "Power average mode (" + str(TRACEaverage.get()) + ") "
17523 
17524  if ZEROstuffing.get() > 0:
17525  txt = txt + "Zero Stuffing = " + str(ZEROstuffing.get())
17526  # Runstatus and level information
17527  if (RUNstatus.get() == 0) and (SingleShotSA.get() == 0):
17528  txt = txt + " Stopped "
17529  elif SingleShotSA.get() == 1:
17530  txt = txt + " Single Shot Trace "
17531  else:
17532  if FreqDisp.get() == 1:
17533  txt = txt + " Running "
17534  else:
17535  txt = txt + " Display off "
17536  x = X0LF
17537  y = Y0TF+GRHF+34
17538  IDtxt = Freqca.create_text (x, y, text=txt, anchor=W, fill=COLORtext)
17539 
17541  global SMPfft, FFTwindow
17542  global SMPfftpwrTwo, BodeDisp
17543  global TRACEresetFreq, FreqTraceMode, LoopNum, FSweepMode, FSweepCont
17544 
17545  # First some subroutines to set specific variables
17546  if BodeDisp.get() == 0:
17547  if FFTwindow.get() != 8:
17548  SMPfft = 2 ** int(SMPfftpwrTwo.get()) # Calculate the number of FFT samples from SMPfftpwrtwo
17549 
17551  if FreqTraceMode.get() == 1 and TRACEresetFreq == False:
17552  TRACEresetFreq = True # Clear the memory for averaging or peak
17553  if FreqTraceMode.get() == 2 and LoopNum.get() == 1 and FSweepMode.get() > 0 and FSweepCont.get() == 0 and BodeDisp.get() >0:
17554  TRACEresetFreq = True # Clear the memory for peak hold when using sweep generator
17555 
17556 def CALCFFTwindowshape(): # Make the FFTwindowshape for the windowing function
17557  global FFTbandwidth # The FFT bandwidth
17558  global FFTwindow # Which FFT window number is selected
17559  global FFTwindowname # The name of the FFT window function
17560  global FFTwindowshape # The window shape
17561  global AWGSAMPLErate, SAMPLErate, BaseSampleRate # The sample rate
17562  global SMPfft # Number of FFT samples
17563  global LastWindow, LastSMPfft
17564 
17565  if LastWindow == FFTwindow.get() and LastSMPfft == SMPfft:
17566  # recalculate window only if something changed
17567  return
17568  # FFTname and FFTbandwidth in milliHz
17569  FFTwindowname = "No such window"
17570  FFTbw = 0
17571 
17572  if FFTwindow.get() == 0:
17573  FFTwindowname = " Rectangular (no) window (B=1) "
17574  FFTbw = 1.0
17575 
17576  if FFTwindow.get() == 1:
17577  FFTwindowname = " Cosine window (B=1.24) "
17578  FFTbw = 1.24
17579 
17580  if FFTwindow.get() == 2:
17581  FFTwindowname = " Triangular window (B=1.33) "
17582  FFTbw = 1.33
17583 
17584  if FFTwindow.get() == 3:
17585  FFTwindowname = " Hann window (B=1.5) "
17586  FFTbw = 1.5
17587 
17588  if FFTwindow.get() == 4:
17589  FFTwindowname = " Blackman window (B=1.73) "
17590  FFTbw = 1.73
17591 
17592  if FFTwindow.get() == 5:
17593  FFTwindowname = " Nuttall window (B=2.02) "
17594  FFTbw = 2.02
17595 
17596  if FFTwindow.get() == 6:
17597  FFTwindowname = " Flat top window (B=3.77) "
17598  FFTbw = 3.77
17599 
17600  if FFTwindow.get() == 7:
17601  FFTwindowname = FFTUserWindowString
17602  FFTbw = 0.0
17603  try:
17604  FFTwindowshape = eval(FFTUserWindowString)
17605  except:
17606  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
17607  print( "Filling FFT window with Ones")
17608  elif FFTwindow.get() == 8: # window shape array read from csv file
17609  FFTwindowname = "Window Shape From file"
17610  FFTbw = 0.0
17611  else:
17612  FFTbandwidth = int(FFTbw * (SAMPLErate/2.0) / float(SMPfft))
17613  # Calculate the shape
17614  FFTwindowshape = numpy.ones(SMPfft) # Initialize with ones
17615  n = 0
17616  while n < SMPfft:
17617  # Cosine window function - medium-dynamic range B=1.24
17618  if FFTwindow.get() == 1:
17619  w = math.sin(math.pi * n / (SMPfft - 1))
17620  FFTwindowshape[n] = w * 1.571
17621  # Triangular non-zero endpoints - medium-dynamic range B=1.33
17622  if FFTwindow.get() == 2:
17623  w = (2.0 / SMPfft) * ((SMPfft/ 2.0) - abs(n - (SMPfft - 1) / 2.0))
17624  FFTwindowshape[n] = w * 2.0
17625  # Hann window function - medium-dynamic range B=1.5
17626  if FFTwindow.get() == 3:
17627  w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1))
17628  FFTwindowshape[n] = w * 2.000
17629  # Blackman window, continuous first derivate function - medium-dynamic range B=1.73
17630  if FFTwindow.get() == 4:
17631  w = 0.42 - 0.5 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.08 * math.cos(4 * math.pi * n / (SMPfft - 1))
17632  FFTwindowshape[n] = w * 2.381
17633  # Nuttall window, continuous first derivate function - high-dynamic range B=2.02
17634  if FFTwindow.get() == 5:
17635  w = 0.355768 - 0.487396 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 0.144232 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.012604 * math.cos(6 * math.pi * n / (SMPfft - 1))
17636  FFTwindowshape[n] = w * 2.811
17637  # Flat top window, medium-dynamic range, extra wide bandwidth B=3.77
17638  if FFTwindow.get() == 6:
17639  w = 1.0 - 1.93 * math.cos(2 * math.pi * n / (SMPfft - 1)) + 1.29 * math.cos(4 * math.pi * n / (SMPfft - 1))- 0.388 * math.cos(6 * math.pi * n / (SMPfft - 1)) + 0.032 * math.cos(8 * math.pi * n / (SMPfft - 1))
17640  FFTwindowshape[n] = w * 1.000
17641  n = n + 1
17642  LastWindow = FFTwindow.get()
17643  LastSMPfft = SMPfft
17644 
17646  global FFTUserWindowString, freqwindow
17647 
17648  TempString = FFTUserWindowString
17649  FFTUserWindowString = askstring("User FFT Window", "Current User Window: " + FFTUserWindowString + "\n\nNew Window:\n", initialvalue=FFTUserWindowString, parent=freqwindow)
17650  if (FFTUserWindowString == None): # If Cancel pressed, then None
17651  FFTUserWindowString = TempString
17652 
17654  global FFTwindowshape, SMPfft, LastSMPfft, FFTwindow, LastWindow
17655 
17656  # Read values from CVS file
17657  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=freqwindow)
17658  try:
17659  CSVFile = open(filename)
17660  csv_f = csv.reader(CSVFile)
17661  FFTwindowshape = []
17662  for row in csv_f:
17663  try:
17664  FFTwindowshape.append(float(row[0]))
17665  except:
17666  print( 'skipping non-numeric row')
17667  FFTwindowshape = numpy.array(FFTwindowshape)
17668  CSVFile.close()
17669  SMPfft = len(FFTwindowshape)
17670  LastSMPfft = SMPfft
17671  LastWindow = FFTwindow.get()
17672  print( SMPfft)
17673  except:
17674  showwarning("WARNING","No such file found or wrong format!")
17675 #
17677  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
17678 
17679  FCursor = event.x
17680  dBCursor = event.y
17681  if RUNstatus.get() == 0:
17683  Freqca.bind('<MouseWheel>', onCanvasFreqClickScroll)
17684  Freqca.bind("<Button-4>", onCanvasFreqClickScroll)# with Linux OS
17685  Freqca.bind("<Button-5>", onCanvasFreqClickScroll)
17686 #
17688  global ShowFCur, ShowdBCur, FCursor, dBCursor, RUNstatus, Freqca
17689 
17690  if event.widget == Freqca:
17691  ShiftKeyDwn = event.state & 1
17692  if ShowFCur.get() > 0 and ShiftKeyDwn == 0:
17693  # respond to Linux or Windows wheel event
17694  if event.num == 5 or event.delta == -120:
17695  FCursor -= 1
17696  if event.num == 4 or event.delta == 120:
17697  FCursor += 1
17698  elif ShowdBCur.get() > 0 or ShiftKeyDwn == 1:
17699  # respond to Linux or Windows wheel event
17700  if event.num == 5 or event.delta == -120:
17701  dBCursor += 1
17702  if event.num == 4 or event.delta == 120:
17703  dBCursor -= 1
17704  if RUNstatus.get() == 0:
17706 #
17708  global X0LF # Left top X value
17709  global Y0TF # Left top Y value
17710  global GRWF # Screenwidth
17711  global GRHF # Screenheight
17712  global FontSize
17713  global Freqca, MarkerLoc, SAMPLErate, BaseSampleRate
17714  global COLORgrid, COLORtext, HScale, ShowC1_VdB, ShowC2_VdB
17715  global COLORtrace1, COLORtrace2, StartFreqEntry, StopFreqEntry
17716  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF
17717  global SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry, SAvertmax, SAvertmin
17718 
17719  if (RUNstatus.get() == 0):
17720  MarkerFreqNum = MarkerFreqNum + 1
17721  COLORmarker = COLORgrid
17722  if ShowC1_VdB.get() == 1:
17723  COLORmarker = COLORtrace1
17724  elif ShowC2_VdB.get() == 1:
17725  COLORmarker = COLORtrace2
17726  try:
17727  StartFrequency = float(StartFreqEntry.get())
17728  except:
17729  StartFreqEntry.delete(0,"end")
17730  StartFreqEntry.insert(0,100)
17731  StartFrequency = 100
17732  try:
17733  StopFrequency = float(StopFreqEntry.get())
17734  except:
17735  StopFreqEntry.delete(0,"end")
17736  StopFreqEntry.insert(0,100)
17737  StopFrequency = 100
17738  # draw X at marker point and number
17739  Freqca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
17740  Freqca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
17741  Freqca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
17742  # Vertical conversion factors (level dBs) and border limits
17743  Yconv = float(GRHF) / (Vdiv.get() * DBdivlist[DBdivindex.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
17744  YVconv = float(GRHF) / (SAvertmax - SAvertmin) # * Vdiv.get()
17745  Yc = float(Y0TF) + Yconv * (DBlevel.get()) # Yc is the 0 dBm position, can be outside the screen!
17746  YVc = float(Y0TF) + YVconv * SAvertmax
17747  Yphconv = float(GRHF) / 360
17748  Yp = float(Y0TF) + Yphconv + 180
17749  # Horizontal conversion factors (frequency Hz) and border limits
17750  if HScale.get() == 1:
17751  LogFStop = math.log10(StopFrequency)
17752  try:
17753  LogFStart = math.log10(StartFrequency)
17754  except:
17755  LogFStart = 0.0
17756  LogFpixel = (LogFStop - LogFStart) / GRWF
17757  xfreq = 10**(((event.x-X0LF)*LogFpixel) + LogFStart)
17758  else:
17759  Fpixel = (StopFrequency - StartFrequency) / GRWF # Frequency step per screen pixel
17760  xfreq = ((event.x-X0LF)*Fpixel)+StartFrequency
17761  #
17762  try:
17763  LogVStop = math.log10(SAvertmax)
17764  except:
17765  LogVStop = 0.0
17766  try:
17767  LogVStart = math.log10(SAvertmin)
17768  except:
17769  LogVStart = -10
17770  LogVpixel = (LogVStop - LogVStart) / GRHF
17771  #
17772  XFString = ' {0:.2f} '.format(xfreq)
17773  if SAVScale.get() == 0:
17774  yvdB = ((Yc-event.y)/Yconv)
17775  VdBString = ' {0:.3f} '.format(yvdB)
17776  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
17777  else:
17778  if SAVScale.get() == 1:
17779  yvdB = ((YVc-event.y)/YVconv)
17780  VdBString = ' {0:.3f} '.format(yvdB)
17781  else:
17782  Vlog = ((YVc - event.y) * LogVpixel) + LogVStart
17783  yvdB = 10**Vlog
17784  VdBString = ' {:.2e} '.format(yvdB)
17785  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " Vrms"
17786 
17787  if MarkerFreqNum > 1:
17788  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17789  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
17790  if SAVScale.get() == 0:
17791  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17792  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
17793  else:
17794  if SAVScale.get() == 1:
17795  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
17796  else:
17797  DeltaV = ' {0:.2e} '.format(yvdB-PrevdBV)
17798  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " Vrms"
17799  x = X0LF + 5
17800  y = Y0TF + 3 + (MarkerFreqNum*10)
17801  Justify = 'w'
17802  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
17803  x = X0LF + GRWF - 5
17804  y = Y0TF + 3 + (MarkerFreqNum*10)
17805  Justify = 'e'
17806  if MarkerLoc == 'LL' or MarkerLoc == 'll':
17807  x = X0LF + 5
17808  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
17809  Justify = 'w'
17810  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
17811  x = X0LF + GRWF - 5
17812  y = Y0TF + GRHF + 3 - (MarkerFreqNum*10)
17813  Justify = 'e'
17814  Freqca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
17815  PrevdBV = yvdB
17816  PrevF = xfreq
17817 #
17818 def onCanvasSAOne(event):
17819  global ShowC1_VdB
17820  if ShowC1_VdB.get() == 0:
17821  ShowC1_VdB.set(1)
17822  else:
17823  ShowC1_VdB.set(0)
17824 #
17825 def onCanvasSATwo(event):
17826  global ShowC2_VdB
17827  if ShowC2_VdB.get() == 0:
17828  ShowC2_VdB.set(1)
17829  else:
17830  ShowC2_VdB.set(0)
17831 #
17832 def onCanvasSAThree(event):
17833  global ShowC1_P
17834  if ShowC1_P.get() == 0:
17835  ShowC1_P.set(1)
17836  else:
17837  ShowC1_P.set(0)
17838 #
17839 def onCanvasSAFour(event):
17840  global ShowC2_P
17841  if ShowC2_P.get() == 0:
17842  ShowC2_P.set(1)
17843  else:
17844  ShowC2_P.set(0)
17845 #
17846 def onCanvasSAFive(event):
17847  global ShowMarker
17848  if ShowMarker.get() == 0:
17849  ShowMarker.set(1)
17850  else:
17851  ShowMarker.set(0)
17852 #
17853 def onCanvasSASix(event):
17854  global ShowRA_VdB
17855  if ShowRA_VdB.get() == 0:
17856  ShowRA_VdB.set(1)
17857  else:
17858  ShowRA_VdB.set(0)
17859 #
17860 def onCanvasSASeven(event):
17861  global ShowRB_VdB
17862  if ShowRB_VdB.get() == 0:
17863  ShowRB_VdB.set(1)
17864  else:
17865  ShowRB_VdB.set(0)
17866 #
17867 def onCanvasSAEight(event):
17868  global ShowMathSA
17869  ShowMathSA.set(2)
17870 #
17871 def onCanvasSANine(event):
17872  global ShowMathSA
17873  ShowMathSA.set(1)
17874 #
17875 def onCanvasSAZero(event):
17876  global ShowMathSA
17877  ShowMathSA.set(0)
17878 #
17879 def onCanvasSASnap(event):
17880  BSTOREtraceSA()
17881 #
17882 def onCanvasSANormal(event):
17883  BNormalmode()
17884 #
17885 def onCanvasSAPeak(event):
17886  BPeakholdmode()
17887 
17888 def onCanvasSAReset(event):
17889  BResetFreqAvg()
17890 #
17892  BAveragemode()
17893 #
17894 def onCanvasShowFcur(event):
17895  global ShowFCur
17896  if ShowFCur.get() == 0:
17897  ShowFCur.set(1)
17898  else:
17899  ShowFCur.set(0)
17900 #
17902  global ShowdBCur
17903  if ShowdBCur.get() == 1:
17904  ShowdBCur.set(0)
17905  else:
17906  ShowdBCur.set(1)
17907 #
17908 def onCanvasShowPcur(event):
17909  global ShowdBCur
17910  if ShowdBCur.get() == 2:
17911  ShowdBCur.set(0)
17912  else:
17913  ShowdBCur.set(2)
17914 #
17916  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus, Bodeca
17917 
17918  BPCursor = event.x
17919  BdBCursor = event.y
17920  if RUNstatus.get() == 0:
17922  #Bodeca.bind_all('<MouseWheel>', onCanvasBodeClickScroll)
17923  Bodeca.bind('<MouseWheel>', onCanvasBodeClickScroll)
17924  Bodeca.bind("<Button-4>", onCanvasBodeClickScroll)# with Linux OS
17925  Bodeca.bind("<Button-5>", onCanvasBodeClickScroll)
17926 #
17928  global ShowBPCur, ShowBdBCur, BPCursor, BdBCursor, RUNstatus
17929 
17930  # print event.state
17931  shift_key = event.state & 1
17932  if ShowBPCur.get() > 0 and shift_key == 0:
17933  # respond to Linux or Windows wheel event
17934  if event.num == 5 or event.delta == -120:
17935  BPCursor -= 1
17936  if event.num == 4 or event.delta == 120:
17937  BPCursor += 1
17938  elif ShowBdBCur.get() > 0 or shift_key == 1:
17939  # respond to Linux or Windows wheel event
17940  if event.num == 5 or event.delta == -120:
17941  BdBCursor += 1
17942  if event.num == 4 or event.delta == 120:
17943  BdBCursor -= 1
17944  if RUNstatus.get() == 0:
17946 #
17948  global X0LBP # Left top X value
17949  global Y0TBP # Left top Y value
17950  global GRWBP # Screenwidth
17951  global GRHBP # Screenheight
17952  global FontSize
17953  global Bodeca, MarkerLoc, SAMPLErate
17954  global COLORgrid, COLORtext, HScaleBP, ShowCA_VdB, ShowCB_VdB, DBdivindexBP
17955  global COLORtrace1, COLORtrace2, COLORtrace6, StartBodeEntry, StopBodeEntry, DBlevelBP
17956  global AWGSAMPLErate, RUNstatus, COLORtext, MarkerFreqNum, PrevdBV, PrevF, Vdiv
17957 
17958  if (RUNstatus.get() == 0):
17959  MarkerFreqNum = MarkerFreqNum + 1
17960  COLORmarker = COLORtrace6 # COLORgrid
17961  if ShowCA_VdB.get() == 1:
17962  COLORmarker = COLORtrace1
17963  elif ShowCB_VdB.get() == 1:
17964  COLORmarker = COLORtrace2
17965  try:
17966  EndFreq = float(StopBodeEntry.get())
17967  except:
17968  StopBodeEntry.delete(0,"end")
17969  StopBodeEntry.insert(0,10000)
17970  EndFreq = 10000
17971  try:
17972  BeginFreq = float(StartBodeEntry.get())
17973  except:
17974  StartBodeEntry.delete(0,"end")
17975  StartBodeEntry.insert(0,100)
17976  BeginFreq = 100
17977  # draw X at marker point and number
17978  Bodeca.create_line(event.x-4, event.y-4,event.x+4, event.y+5, fill=COLORmarker)
17979  Bodeca.create_line(event.x+4, event.y-4,event.x-4, event.y+5, fill=COLORmarker)
17980  Bodeca.create_text(event.x+4, event.y, text=str(MarkerFreqNum), fill=COLORmarker, anchor="w", font=("arial", FontSize ))
17981  # Vertical conversion factors (level dBs) and border limits
17982  Yconv = float(GRHBP) / (Vdiv.get() * DBdivlist[DBdivindexBP.get()]) # Conversion factors, Yconv is the number of screenpoints per dB
17983  Yc = float(Y0TBP) + Yconv * (DBlevelBP.get()) # Yc is the 0 dBm position, can be outside the screen!
17984  Yphconv = float(GRHBP) / 360
17985  Yp = float(Y0TBP) + Yphconv + 180
17986  x1 = X0LBP + 14
17987  x2 = x1 + GRWBP
17988  # Horizontal conversion factors (frequency Hz) and border limits
17989  if HScaleBP.get() == 1:
17990  LogFStop = math.log10(EndFreq)
17991  try:
17992  LogFStart = math.log10(BeginFreq)
17993  except:
17994  LogFStart = 0.0
17995  LogFpixel = (LogFStop - LogFStart) / GRWBP
17996  xfreq = 10**(((event.x-x1)*LogFpixel) + LogFStart)
17997  else:
17998  Fpixel = (EndFreq - BeginFreq) / GRWBP # Frequency step per screen pixel
17999  xfreq = ((event.x-x1)*Fpixel)+BeginFreq
18000 
18001  yvdB = ((Yc-event.y)/Yconv)
18002  VdBString = ' {0:.1f} '.format(yvdB)
18003  XFString = ' {0:.2f} '.format(xfreq)
18004  V_label = str(MarkerFreqNum) + " " + XFString + " Hz, " + VdBString + " dBV"
18005  if MarkerFreqNum > 1:
18006  DeltaV = ' {0:.3f} '.format(yvdB-PrevdBV)
18007  DeltaF = ' {0:.2f} '.format(xfreq-PrevF)
18008  V_label = V_label + " Delta " + DeltaF + " Hz, " + DeltaV + " dBV"
18009  x = x1 + 5
18010  y = Y0TBP + 3 + (MarkerFreqNum*10)
18011  Justify = 'w'
18012  if MarkerLoc == 'UR' or MarkerLoc == 'ur':
18013  x = x2 - 5
18014  y = Y0TBP + 3 + (MarkerFreqNum*10)
18015  Justify = 'e'
18016  if MarkerLoc == 'LL' or MarkerLoc == 'll':
18017  x = x1 + 5
18018  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18019  Justify = 'w'
18020  if MarkerLoc == 'LR' or MarkerLoc == 'lr':
18021  x = x2 - 5
18022  y = Y0TBP + GRHBP + 3 - (MarkerFreqNum*10)
18023  Justify = 'e'
18024  Bodeca.create_text(x, y, text=V_label, fill=COLORmarker, anchor=Justify, font=("arial", FontSize ))
18025  PrevdBV = yvdB
18026  PrevF = xfreq
18027 #
18028 def onCanvasBdOne(event):
18029  global ShowCA_VdB
18030  if ShowCA_VdB.get() == 0:
18031  ShowCA_VdB.set(1)
18032  else:
18033  ShowCA_VdB.set(0)
18034 #
18035 def onCanvasBdTwo(event):
18036  global ShowCB_VdB
18037  if ShowCB_VdB.get() == 0:
18038  ShowCB_VdB.set(1)
18039  else:
18040  ShowCB_VdB.set(0)
18041 #
18042 def onCanvasBdThree(event):
18043  global ShowCA_P
18044  if ShowCA_P.get() == 0:
18045  ShowCA_P.set(1)
18046  else:
18047  ShowCA_P.set(0)
18048 #
18049 def onCanvasBdFour(event):
18050  global ShowCB_P
18051  if ShowCB_P.get() == 0:
18052  ShowCB_P.set(1)
18053  else:
18054  ShowCB_P.set(0)
18055 #
18056 def onCanvasBdFive(event):
18057  global ShowMarkerBP
18058  if ShowMarkerBP.get() == 0:
18059  ShowMarkerBP.set(1)
18060  else:
18061  ShowMarkerBP.set(0)
18062 #
18063 def onCanvasBdSix(event):
18064  global ShowRA_VdB
18065  if ShowRA_VdB.get() == 0:
18066  ShowRA_VdB.set(1)
18067  else:
18068  ShowRA_VdB.set(0)
18069 #
18070 def onCanvasBdSeven(event):
18071  global ShowRB_VdB
18072  if ShowRB_VdB.get() == 0:
18073  ShowRB_VdB.set(1)
18074  else:
18075  ShowRB_VdB.set(0)
18076 #
18077 def onCanvasBdEight(event):
18078  global ShowMathBP
18079  ShowMathBP.set(2)
18080 #
18081 def onCanvasBdNine(event):
18082  global ShowMathBP
18083  ShowMathBP.set(1)
18084 #
18085 def onCanvasBdZero(event):
18086  global ShowMathBP
18087  ShowMathBP.set(0)
18088 #
18089 def onCanvasBdSnap(event):
18090  BSTOREtraceBP()
18091 #
18093  global ShowBPCur
18094  if ShowBPCur.get() == 0:
18095  ShowBPCur.set(1)
18096  else:
18097  ShowBPCur.set(0)
18098 #
18100  global ShowBdBCur
18101  if ShowBdBCur.get() == 1:
18102  ShowBdBCur.set(0)
18103  else:
18104  ShowBdBCur.set(1)
18105 #
18107  global ShowBdBCur
18108  if ShowBdBCur.get() == 2:
18109  ShowBdBCur.set(0)
18110  else:
18111  ShowBdBCur.set(2)
18112 #
18113 def onAWGAscroll(event):
18114  global AWGAShape
18115 
18116  onTextScroll(event)
18117  time.sleep(0.05)
18118  ReMakeAWGwaves()
18119  time.sleep(0.05)
18120 #
18121 def onAWGBscroll(event):
18122  global AWGBShape
18123 
18124  onTextScroll(event)
18125  time.sleep(0.05)
18126  ReMakeAWGwaves()
18127  time.sleep(0.05)
18128 #
18129 def onTextScroll(event): # Use mouse wheel to scroll entry values, august 7
18130  button = event.widget
18131  cursor_position = button.index(INSERT) # get current cursor position
18132  Pos = cursor_position
18133  OldVal = button.get() # get current entry string
18134  OldValfl = float(OldVal) # and its value
18135  NewVal = OldValfl
18136  Len = len(OldVal)
18137  Dot = OldVal.find (".") # find decimal point position
18138  Decimals = Len - Dot - 1
18139  if Dot == -1 : # no point
18140  Decimals = 0
18141  Step = 10**(Len - Pos)
18142  elif Pos <= Dot : # no point left of position
18143  Step = 10**(Dot - Pos)
18144  else:
18145  Step = 10**(Dot - Pos + 1)
18146  # respond to Linux or Windows wheel event
18147  if event.num == 5 or event.delta == -120:
18148  NewVal = OldValfl - Step
18149  if event.num == 4 or event.delta == 120:
18150  NewVal = OldValfl + Step
18151  FormatStr = "{0:." + str(Decimals) + "f}"
18152  NewStr = FormatStr.format(NewVal)
18153  NewDot = NewStr.find (".")
18154  NewPos = Pos + NewDot - Dot
18155  if Decimals == 0 :
18156  NewLen = len(NewStr)
18157  NewPos = Pos + NewLen - Len
18158  button.delete(0, END) # remove old entry
18159  button.insert(0, NewStr) # insert new entry
18160  button.icursor(NewPos) # resets the insertion cursor
18161 #
18162 def onAWGAkey(event):
18163  global AWGAShape
18164 
18165  onTextKey(event)
18166  ReMakeAWGwaves()
18167 #
18168 def onAWGBkey(event):
18169  global AWGBShape
18170 
18171  onTextKey(event)
18172  ReMakeAWGwaves()
18173 #
18174 def onTextKeyAWG(event):
18175  onTextKey(event)
18176  ReMakeAWGwaves()
18177 #
18178 # Use Arriw keys to inc dec entry values
18179 def onTextKey(event):
18180  button = event.widget
18181  cursor_position = button.index(INSERT) # get current cursor position
18182  Pos = cursor_position
18183  OldVal = button.get() # get current entry string
18184  OldValfl = float(OldVal) # and its value
18185  Len = len(OldVal)
18186  Dot = OldVal.find (".") # find decimal point position
18187  Decimals = Len - Dot - 1
18188  if Dot == -1 : # no point
18189  Decimals = 0
18190  Step = 10**(Len - Pos)
18191  elif Pos <= Dot : # no point left of position
18192  Step = 10**(Dot - Pos)
18193  else:
18194  Step = 10**(Dot - Pos + 1)
18195  if platform.system() == "Windows":
18196  if event.keycode == 38: # increment digit for up arrow key
18197  NewVal = OldValfl + Step
18198  elif event.keycode == 40: # decrement digit for down arrow
18199  NewVal = OldValfl - Step
18200  else:
18201  return
18202  elif platform.system() == "Linux":
18203  if event.keycode == 111: # increment digit for up arrow key
18204  NewVal = OldValfl + Step
18205  elif event.keycode == 116: # decrement digit for down arrow
18206  NewVal = OldValfl - Step
18207  else:
18208  return
18209  elif platform.system() == "Darwin":
18210  if event.keycode == 0x7D: # increment digit for up arrow key
18211  NewVal = OldValfl + Step
18212  elif event.keycode == 0x7E: # decrement digit for down arrow
18213  NewVal = OldValfl - Step
18214  else:
18215  return
18216  else:
18217  return
18218 #
18219  FormatStr = "{0:." + str(Decimals) + "f}"
18220  NewStr = FormatStr.format(NewVal)
18221  NewDot = NewStr.find (".")
18222  NewPos = Pos + NewDot - Dot
18223  if Decimals == 0 :
18224  NewLen = len(NewStr)
18225  NewPos = Pos + NewLen - Len
18226  button.delete(0, END) # remove old entry
18227  button.insert(0, NewStr) # insert new entry
18228  button.icursor(NewPos) # resets the insertion cursor
18229 #
18230 #
18231 def onSpinBoxScroll(event):
18232  spbox = event.widget
18233  if sys.version_info[0] == 3 and sys.version_info[1] > 6: # Spin Boxes do this automatically in Python > 3.6 apparently
18234  return
18235  if event.num == 4 or event.delta > 0: # if event.delta > 0: # increment digit
18236  spbox.invoke('buttonup')
18237  if event.num == 5 or event.delta < 0:
18238  spbox.invoke('buttondown')
18239 #
18240 # ================ Make awg sub window ==========================
18242  global AWGAMode, AWGATerm, AWGAShape, AWGSync, awgwindow, AWGAPhaseDelay, AWGBPhaseDelay
18243  global AWGBMode, AWGBTerm, AWGBShape, AWGScreenStatus, AWGARepeatFlag, AWGBRepeatFlag
18244  global AWGABurstFlag, AWGBBurstFlag, AWGAShapeLabel, AWGBShapeLabel, AWGShowAdvanced
18245  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGAPhaseEntry, AWGADutyCycleEntry
18246  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBPhaseEntry, AWGBDutyCycleEntry
18247  global AWGALength, AWGBLength, RevDate, phasealab, phaseblab, AWGAModeLabel, AWGBModeLabel
18248  global AWGAIOMode, AWGBIOMode, duty1lab, duty2lab, awgaph, awgadel, awgbph, awgbdel
18249  global AwgLayout, AWG_Amp_Mode, awgsync, SWRev # 0 = Min/Max mode, 1 = Amp/Offset
18250  global amp1lab, amp2lab, off1lab, off2lab, Reset_Freq, AWG_2X, BisCompA, FWRevOne
18251  global ModeAMenu, ShapeAMenu, amp1lab, off1lab, freq1lab, awgaph, awgadel, ModeBMenu, ShapeBMenu
18252  global amp2lab, off2lab, freq2lab, awgbph, awgbdel, bcompa, awgsync
18253  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise, NoiseList
18254 
18255  if AWGScreenStatus.get() == 0:
18256  AWGScreenStatus.set(1)
18257 
18258  awgwindow = Toplevel()
18259  awgwindow.title("AWG Controls " + SWRev + RevDate)
18260  awgwindow.resizable(FALSE,FALSE)
18261  awgwindow.geometry('+0+100')
18262  awgwindow.protocol("WM_DELETE_WINDOW", DestroyAWGScreen)
18263  #
18264  frame2 = LabelFrame(awgwindow, text="AWG CH A", style="A10R1.TLabelframe")
18265  frame3 = LabelFrame(awgwindow, text="AWG CH B", style="A10R2.TLabelframe")
18266  #
18267  if AwgLayout == "Horz":
18268  frame2.pack(side=LEFT, expand=1, fill=X)
18269  frame3.pack(side=LEFT, expand=1, fill=X)
18270  else:
18271  frame2.pack(side=TOP, expand=1, fill=Y)
18272  frame3.pack(side=TOP, expand=1, fill=Y)
18273  # now AWG A
18274  # AWG enable sub frame
18275  awg1eb = Frame( frame2 )
18276  awg1eb.pack(side=TOP)
18277  ModeAMenu = Menubutton(awg1eb, text="Mode", style="W5.TButton")
18278  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
18279  ModeAMenu["menu"] = ModeAMenu.menu
18280  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
18281  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
18282  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
18283  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
18284  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
18285  ModeAMenu.menu.add_separator()
18286  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
18287  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
18288  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
18289  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
18290  ModeAMenu.pack(side=LEFT, anchor=W)
18291  ShapeAMenu = Menubutton(awg1eb, text="Shape", style="W6.TButton")
18292  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
18293  ShapeAMenu["menu"] = ShapeAMenu.menu
18294  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
18295  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
18296  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
18297  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
18298  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
18299  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
18300  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
18301  if AWGShowAdvanced.get() > 0:
18302  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
18303  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
18304  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
18305  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
18306  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
18307  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
18308  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
18309  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
18310  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
18311  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
18312  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
18313  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
18314  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
18315  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
18316  else:
18317  ShapeAMenu.menu.add_separator()
18318  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
18319  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
18320  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
18321  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
18322  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
18323  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
18324  ShapeAMenu.pack(side=LEFT, anchor=W)
18325  #
18326  AWGAModeLabel = Label(frame2, text="AWG A Mode")
18327  AWGAModeLabel.pack(side=TOP)
18328  AWGAShapeLabel = Label(frame2, text="AWG A Shape")
18329  AWGAShapeLabel.pack(side=TOP)
18330  #
18331  awg1ampl = Frame( frame2 )
18332  awg1ampl.pack(side=TOP)
18333  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
18334  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
18335  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
18336  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18337  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
18338  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
18339  AWGAAmplEntry.pack(side=LEFT, anchor=W)
18340  AWGAAmplEntry.delete(0,"end")
18341  AWGAAmplEntry.insert(0,0.0)
18342  amp1lab = Label(awg1ampl) #, text="Min Ch A")
18343  amp1lab.pack(side=LEFT, anchor=W)
18344  #
18345  awg1off = Frame( frame2 )
18346  awg1off.pack(side=TOP)
18347  AWGAOffsetEntry = Entry(awg1off, width=5, cursor='double_arrow')
18348  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
18349  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
18350  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18351  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
18352  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
18353  AWGAOffsetEntry.pack(side=LEFT, anchor=W)
18354  AWGAOffsetEntry.delete(0,"end")
18355  AWGAOffsetEntry.insert(0,0.0)
18356  off1lab = Label(awg1off) #, text="Max Ch A")
18357  off1lab.pack(side=LEFT, anchor=W)
18358  if AWG_Amp_Mode.get() == 0:
18359  amp1lab.config(text = "Min Ch A" ) # change displayed value
18360  off1lab.config(text = "Max Ch A" ) # change displayed value
18361  else:
18362  amp1lab.config(text = "Amp Ch A" )
18363  off1lab.config(text = "Off Ch A" )
18364  # AWG Frequency sub frame
18365  awg1freq = Frame( frame2 )
18366  awg1freq.pack(side=TOP)
18367  AWGAFreqEntry = Entry(awg1freq, width=7, cursor='double_arrow')
18368  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
18369  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
18370  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18371  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
18372  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
18373  AWGAFreqEntry.pack(side=LEFT, anchor=W)
18374  AWGAFreqEntry.delete(0,"end")
18375  AWGAFreqEntry.insert(0,100.0)
18376  freq1lab = Label(awg1freq, text="Freq Ch A")
18377  freq1lab.pack(side=LEFT, anchor=W)
18378  # AWG Phase or delay select sub frame
18379  # AWG Phase entry sub frame
18380  awg1phase = Frame( frame2 )
18381  awg1phase.pack(side=TOP)
18382  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
18383  awgaph.pack(side=LEFT, anchor=W)
18384  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
18385  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
18386  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
18387  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18388  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
18389  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
18390  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
18391  AWGAPhaseEntry.delete(0,"end")
18392  AWGAPhaseEntry.insert(0,0)
18393  phasealab = Label(awg1phase, text="Deg")
18394  phasealab.pack(side=LEFT, anchor=W)
18395  # AWG duty cycle frame
18396  awg1dc = Frame( frame2 )
18397  awg1dc.pack(side=TOP)
18398  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
18399  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
18400  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
18401  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18402  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
18403  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
18404  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
18405  AWGADutyCycleEntry.delete(0,"end")
18406  AWGADutyCycleEntry.insert(0,50)
18407  duty1lab = Label(awg1dc, text="%")
18408  duty1lab.pack(side=LEFT, anchor=W)
18409  #
18410  AWGALength = Label(frame2, text="Length")
18411  AWGALength.pack(side=TOP)
18412  # Noise Controls
18413  anoise = Frame( frame2 )
18414  anoise.pack(side=TOP)
18415  AWGANoise = Label(anoise, text="Noise")
18416  AWGANoise.pack(side=LEFT, anchor=W)
18417  AWGAsbnoise = Spinbox(anoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
18418  AWGAsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
18419  AWGAsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18420  AWGAsbnoise.bind("<Button-5>", onSpinBoxScroll)
18421  AWGAsbnoise.pack(side=LEFT, anchor=W)
18422  AWGANoiseEntry = Entry(anoise, width=5, cursor='double_arrow')
18423  AWGANoiseEntry.bind("<Return>", UpdateAwgContRet)
18424  AWGANoiseEntry.bind('<MouseWheel>', onAWGAscroll)
18425  AWGANoiseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
18426  AWGANoiseEntry.bind("<Button-5>", onAWGAscroll)
18427  AWGANoiseEntry.bind('<Key>', onTextKeyAWG)
18428  AWGANoiseEntry.pack(side=LEFT, anchor=W)
18429  AWGANoiseEntry.delete(0,"end")
18430  AWGANoiseEntry.insert(0,0.0)
18431  #
18432  if FWRevOne > 2.16:
18433  awg2x1 = Radiobutton(frame2, text="Both CH 1X", variable=AWG_2X, value=0, command=BAWG2X)
18434  awg2x1.pack(side=TOP)
18435  awg2x2 = Radiobutton(frame2, text="CH A 2X", variable=AWG_2X, value=1, command=BAWG2X)
18436  awg2x2.pack(side=TOP)
18437  awg2x3 = Radiobutton(frame2, text="CH B 2X", variable=AWG_2X, value=2, command=BAWG2X)
18438  awg2x3.pack(side=TOP)
18439  else:
18440  awgsync = Checkbutton(frame2, text="Sync AWG", variable=AWGSync, command=BAWGSync)
18441  awgsync.pack(side=TOP)
18442  # now AWG B
18443  # AWG enable sub frame
18444  awg2eb = Frame( frame3 )
18445  awg2eb.pack(side=TOP)
18446  ModeBMenu = Menubutton(awg2eb, text="Mode", style="W5.TButton")
18447  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
18448  ModeBMenu["menu"] = ModeBMenu.menu
18449  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
18450  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
18451  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
18452  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
18453  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
18454  ModeBMenu.menu.add_separator()
18455  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
18456  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
18457  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
18458  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
18459  ModeBMenu.pack(side=LEFT, anchor=W)
18460  ShapeBMenu = Menubutton(awg2eb, text="Shape", style="W6.TButton")
18461  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
18462  ShapeBMenu["menu"] = ShapeBMenu.menu
18463  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
18464  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
18465  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
18466  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
18467  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
18468  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
18469  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
18470  if AWGShowAdvanced.get() > 0:
18471  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
18472  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
18473  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
18474  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
18475  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
18476  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
18477  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
18478  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
18479  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
18480  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
18481  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
18482  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
18483  else:
18484  ShapeBMenu.menu.add_separator()
18485  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
18486  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
18487  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
18488  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
18489  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
18490  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
18491  ShapeBMenu.pack(side=LEFT, anchor=W)
18492  #
18493  AWGBModeLabel = Label(frame3, text="AWG B Mode")
18494  AWGBModeLabel.pack(side=TOP)
18495  AWGBShapeLabel = Label(frame3, text="AWG B Shape")
18496  AWGBShapeLabel.pack(side=TOP)
18497  #
18498  awg2ampl = Frame( frame3 )
18499  awg2ampl.pack(side=TOP)
18500  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
18501  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
18502  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
18503  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18504  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
18505  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
18506  AWGBAmplEntry.pack(side=LEFT, anchor=W)
18507  AWGBAmplEntry.delete(0,"end")
18508  AWGBAmplEntry.insert(0,0.0)
18509  amp2lab = Label(awg2ampl) #, text="Min Ch B")
18510  amp2lab.pack(side=LEFT, anchor=W)
18511  #
18512  awg2off = Frame( frame3 )
18513  awg2off.pack(side=TOP)
18514  AWGBOffsetEntry = Entry(awg2off, width=5, cursor='double_arrow')
18515  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
18516  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
18517  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18518  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
18519  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
18520  AWGBOffsetEntry.pack(side=LEFT, anchor=W)
18521  AWGBOffsetEntry.delete(0,"end")
18522  AWGBOffsetEntry.insert(0,0.0)
18523  off2lab = Label(awg2off) #, text="Max Ch B")
18524  off2lab.pack(side=LEFT, anchor=W)
18525  if AWG_Amp_Mode.get() == 0:
18526  amp2lab.config(text = "Min Ch B" ) # change displayed value
18527  off2lab.config(text = "Max Ch B" ) # change displayed value
18528  else:
18529  amp2lab.config(text = "Amp Ch B" )
18530  off2lab.config(text = "Off Ch B" )
18531  # AWG Frequency sub frame
18532  awg2freq = Frame( frame3 )
18533  awg2freq.pack(side=TOP)
18534  AWGBFreqEntry = Entry(awg2freq, width=7, cursor='double_arrow')
18535  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
18536  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
18537  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18538  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
18539  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
18540  AWGBFreqEntry.pack(side=LEFT, anchor=W)
18541  AWGBFreqEntry.delete(0,"end")
18542  AWGBFreqEntry.insert(0,100.0)
18543  freq2lab = Label(awg2freq, text="Freq Ch B")
18544  freq2lab.pack(side=LEFT, anchor=W)
18545  # AWG Phase or delay select sub frame
18546  # AWG Phase sub frame
18547  awg2phase = Frame( frame3 )
18548  awg2phase.pack(side=TOP)
18549  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
18550  awgbph.pack(side=LEFT, anchor=W)
18551  AWGBPhaseEntry = Entry(awg2phase, width=4, cursor='double_arrow')
18552  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
18553  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
18554  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18555  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
18556  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
18557  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
18558  AWGBPhaseEntry.delete(0,"end")
18559  AWGBPhaseEntry.insert(0,0)
18560  phaseblab = Label(awg2phase, text="Deg")
18561  phaseblab.pack(side=LEFT, anchor=W)
18562  # AWG duty cycle frame
18563  awg2dc = Frame( frame3 )
18564  awg2dc.pack(side=TOP)
18565  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
18566  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
18567  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
18568  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18569  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
18570  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
18571  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
18572  AWGBDutyCycleEntry.delete(0,"end")
18573  AWGBDutyCycleEntry.insert(0,50)
18574  duty2lab = Label(awg2dc, text="%")
18575  duty2lab.pack(side=LEFT, anchor=W)
18576  #
18577  AWGBLength = Label(frame3, text="Length")
18578  AWGBLength.pack(side=TOP)
18579  # Noise Controls
18580  bnoise = Frame( frame3 )
18581  bnoise.pack(side=TOP)
18582  AWGBNoise = Label(bnoise, text="Noise")
18583  AWGBNoise.pack(side=LEFT, anchor=W)
18584  AWGBsbnoise = Spinbox(bnoise, width=8, cursor='double_arrow', values=NoiseList, command=ReMakeAWGwaves)
18585  AWGBsbnoise.bind('<MouseWheel>', onSpinBoxScroll)
18586  AWGBsbnoise.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18587  AWGBsbnoise.bind("<Button-5>", onSpinBoxScroll)
18588  AWGBsbnoise.pack(side=LEFT, anchor=W)
18589  AWGBNoiseEntry = Entry(bnoise, width=5, cursor='double_arrow')
18590  AWGBNoiseEntry.bind("<Return>", UpdateAwgContRet)
18591  AWGBNoiseEntry.bind('<MouseWheel>', onAWGBscroll)
18592  AWGBNoiseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
18593  AWGBNoiseEntry.bind("<Button-5>", onAWGBscroll)
18594  AWGBNoiseEntry.bind('<Key>', onTextKeyAWG)
18595  AWGBNoiseEntry.pack(side=LEFT, anchor=W)
18596  AWGBNoiseEntry.delete(0,"end")
18597  AWGBNoiseEntry.insert(0,0.0)
18598  #
18599  bcompa = Checkbutton(frame3, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)#SetBCompA)
18600  bcompa.pack(side=TOP)
18601  if FWRevOne > 2.16:
18602  awgsync = Checkbutton(frame3, text="Sync AWG", variable=AWGSync, command=BAWGSync)
18603  awgsync.pack(side=TOP)
18604  #
18605  dismissbutton = Button(frame3, text="Minimize", style="W8.TButton", command=DestroyAWGScreen)
18606  dismissbutton.pack(side=TOP)
18607  if ShowBallonHelp > 0:
18608  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
18609  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
18610  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
18611  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
18612  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
18613  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
18614  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
18615  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
18616  else:
18617  awgwindow.deiconify()
18618 #
18619 def BAWG2X():
18620  global AWG_2X, devx, AWGAIOMode, AWGBIOMode, BisCompA
18621 
18622  ReMakeAWGwaves()
18623  if AWG_2X.get() == 0: # configure board for both AWG channels at 1X sampling
18624  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
18625  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
18626  elif AWG_2X.get() == 1: # configure board for single AWG channel A at 2X sampling
18627  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
18628  devx.ctrl_transfer(0x40, 0x25, 0x0, 0, 0, 0, 100) # set t0 addr DAC A
18629  if AWGBIOMode.get() == 0: # if channel b is not in split I/O mode turn off output
18630  devx.ctrl_transfer(0x40, 0x51, 40, 0, 0, 0, 100) # set IN3 switch to open
18631  devx.ctrl_transfer(0x40, 0x51, 52, 0, 0, 0, 100) # set IN3 switch to open
18632  BisCompA.set(0)
18633  elif AWG_2X.get() == 2: # configure board for single AWG channel B at 2X sampling
18634  devx.ctrl_transfer(0x40, 0x24, 0x1, 0, 0, 0, 100) # set to addr DAC B
18635  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
18636  if AWGAIOMode.get() == 0: # if channel a is not in split I/O mode turn off output
18637  devx.ctrl_transfer(0x40, 0x51, 35, 0, 0, 0, 100) # set IN3 switch to open
18638  devx.ctrl_transfer(0x40, 0x51, 51, 0, 0, 0, 100) # set IN3 switch to open
18639  BisCompA.set(0)
18640 #
18642  global awgwindow, AWGScreenStatus
18643 
18644  # AWGScreenStatus.set(0)
18645  awgwindow.iconify()
18646 #
18647 # ===== Channel B Mux Mode sub Window =======
18649  global MuxScreenStatus, muxwindow, RevDate, DacScreenStatus, DigScreenStatus
18650  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry
18651  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry, SyncButton
18652  global CHB_Alab, CHB_Blab, CHB_Clab, CHB_Dlab, CHBlab, CHBofflab
18653  global CHB_cba, CHB_cbb, CHB_cbc, CHB_cbd
18654  global CHB_Cofflab, CHB_Dofflab, awgsync, SWRev, BorderSize
18655  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxEnb, MuxSync, hipulseimg, lowpulseimg
18656  global ShowRMA, ShowRMB, ShowRMC, ShowRMD
18657  global ChopMuxMode, ChopTrig, DualMuxMode, ShowBallonHelp
18658 
18659  if MuxScreenStatus.get() == 0 and DacScreenStatus.get() == 0 and DigScreenStatus.get() == 0:
18660  MuxScreenStatus.set(1)
18661  #
18662  BAWGEnab() # update AWG settings
18663  #
18664  muxwindow = Toplevel()
18665  muxwindow.title("External Mux " + SWRev + RevDate)
18666  muxwindow.resizable(FALSE,FALSE)
18667  muxwindow.protocol("WM_DELETE_WINDOW", DestroyMuxScreen)
18668  #
18669  frameM = LabelFrame(muxwindow, text="External Analog Mux", style="A10.TLabelframe") #
18670  frameM.pack(side=LEFT, expand=1, fill=X)
18671  #
18672  # Voltage channel CHB-A
18673  frameA = Frame(frameM)
18674  frameA.pack(side=TOP)
18675  CHB_cba = Checkbutton(frameA, text='CB-A', style="Strace2.TCheckbutton", variable=Show_CBA, command=UpdateTimeTrace)
18676  CHB_cba.pack(side=LEFT, anchor=W)
18677  CHB_Asb = Spinbox(frameA, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18678  CHB_Asb.bind('<MouseWheel>', onSpinBoxScroll)
18679  CHB_Asb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18680  CHB_Asb.bind("<Button-5>", onSpinBoxScroll)
18681  CHB_Asb.pack(side=LEFT)
18682  CHB_Asb.delete(0,"end")
18683  CHB_Asb.insert(0,0.5)
18684  #
18685  CHB_Alab = Button(frameA, text="CB-A V/Div", style="Rtrace2.TButton", command=SetScaleMuxA)
18686  CHB_Alab.pack(side=LEFT)
18687  CHB_APosEntry = Entry(frameA, width=5, cursor='double_arrow')
18688  CHB_APosEntry.bind('<Return>', onTextKey)
18689  CHB_APosEntry.bind('<MouseWheel>', onTextScroll)
18690  CHB_APosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18691  CHB_APosEntry.bind("<Button-5>", onTextScroll)
18692  CHB_APosEntry.bind('<Key>', onTextKey)
18693  CHB_APosEntry.pack(side=LEFT)
18694  CHB_APosEntry.delete(0,"end")
18695  CHB_APosEntry.insert(0,2.5)
18696  CHB_Aofflab = Button(frameA, text="CB-A Pos", style="Rtrace2.TButton", command=SetMuxAPoss)
18697  CHB_Aofflab.pack(side=LEFT)
18698  # Voltage channel CHB-B
18699  frameB = Frame(frameM)
18700  frameB.pack(side=TOP)
18701  CHB_cbb = Checkbutton(frameB, text='CB-B', style="Strace6.TCheckbutton", variable=Show_CBB, command=UpdateTimeTrace)
18702  CHB_cbb.pack(side=LEFT, anchor=W)
18703  CHB_Bsb = Spinbox(frameB, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18704  CHB_Bsb.bind('<MouseWheel>', onSpinBoxScroll)
18705  CHB_Bsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18706  CHB_Bsb.bind("<Button-5>", onSpinBoxScroll)
18707  CHB_Bsb.pack(side=LEFT)
18708  CHB_Bsb.delete(0,"end")
18709  CHB_Bsb.insert(0,0.5)
18710  CHB_Blab = Button(frameB, text="CB-B V/Div", style="Rtrace6.TButton", command=SetScaleMuxB)
18711  CHB_Blab.pack(side=LEFT)
18712  CHB_BPosEntry = Entry(frameB, width=5, cursor='double_arrow')
18713  CHB_BPosEntry.bind('<Return>', onTextKey)
18714  CHB_BPosEntry.bind('<MouseWheel>', onTextScroll)
18715  CHB_BPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18716  CHB_BPosEntry.bind("<Button-5>", onTextScroll)
18717  CHB_BPosEntry.bind('<Key>', onTextKey)
18718  CHB_BPosEntry.pack(side=LEFT)
18719  CHB_BPosEntry.delete(0,"end")
18720  CHB_BPosEntry.insert(0,2.5)
18721  CHB_Bofflab = Button(frameB, text="CB-B Pos", style="Rtrace6.TButton", command=SetMuxBPoss)
18722  CHB_Bofflab.pack(side=LEFT)
18723  # Voltage channel B-C
18724  frameC = Frame(frameM)
18725  frameC.pack(side=TOP)
18726  CHB_cbc = Checkbutton(frameC, text='CB-C', style="Strace7.TCheckbutton", variable=Show_CBC, command=UpdateTimeTrace)
18727  CHB_cbc.pack(side=LEFT, anchor=W)
18728  CHB_Csb = Spinbox(frameC, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18729  CHB_Csb.bind('<MouseWheel>', onSpinBoxScroll)
18730  CHB_Csb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18731  CHB_Csb.bind("<Button-5>", onSpinBoxScroll)
18732  CHB_Csb.pack(side=LEFT)
18733  CHB_Csb.delete(0,"end")
18734  CHB_Csb.insert(0,0.5)
18735  #
18736  CHB_Clab = Button(frameC, text="CB-C V/Div", style="Rtrace7.TButton", command=SetScaleMuxC)
18737  CHB_Clab.pack(side=LEFT)
18738  CHB_CPosEntry = Entry(frameC, width=5, cursor='double_arrow')
18739  CHB_CPosEntry.bind('<Return>', onTextKey)
18740  CHB_CPosEntry.bind('<MouseWheel>', onTextScroll)
18741  CHB_CPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18742  CHB_CPosEntry.bind("<Button-5>", onTextScroll)
18743  CHB_CPosEntry.bind('<Key>', onTextKey)
18744  CHB_CPosEntry.pack(side=LEFT)
18745  CHB_CPosEntry.delete(0,"end")
18746  CHB_CPosEntry.insert(0,2.5)
18747  CHB_Cofflab = Button(frameC, text="CB-C Pos", style="Rtrace7.TButton", command=SetMuxCPoss)
18748  CHB_Cofflab.pack(side=LEFT)
18749  # Voltage channel B-D
18750  frameD = Frame(frameM)
18751  frameD.pack(side=TOP)
18752  CHB_cbd = Checkbutton(frameD, text='CB-D', style="Strace4.TCheckbutton", variable=Show_CBD, command=UpdateTimeTrace)
18753  CHB_cbd.pack(side=LEFT, anchor=W)
18754  CHB_Dsb = Spinbox(frameD, width=4, cursor='double_arrow', values=CHvpdiv, command=UpdateTimeTrace)
18755  CHB_Dsb.bind('<MouseWheel>', onSpinBoxScroll)
18756  CHB_Dsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
18757  CHB_Dsb.bind("<Button-5>", onSpinBoxScroll)
18758  CHB_Dsb.pack(side=LEFT)
18759  CHB_Dsb.delete(0,"end")
18760  CHB_Dsb.insert(0,0.5)
18761  CHB_Dlab = Button(frameD, text="CB-D V/Div", style="Rtrace4.TButton", command=SetScaleMuxD)
18762  CHB_Dlab.pack(side=LEFT)
18763  CHB_DPosEntry = Entry(frameD, width=5, cursor='double_arrow')
18764  CHB_DPosEntry.bind('<Return>', onTextKey)
18765  CHB_DPosEntry.bind('<MouseWheel>', onTextScroll)
18766  CHB_DPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
18767  CHB_DPosEntry.bind("<Button-5>", onTextScroll)
18768  CHB_DPosEntry.bind('<Key>', onTextKey)
18769  CHB_DPosEntry.pack(side=LEFT)
18770  CHB_DPosEntry.delete(0,"end")
18771  CHB_DPosEntry.insert(0,2.5)
18772  CHB_Dofflab = Button(frameD, text="CB-D Pos", style="Rtrace4.TButton", command=SetMuxDPoss)
18773  CHB_Dofflab.pack(side=LEFT)
18774  #
18775  frameR = Frame(frameM)
18776  frameR.pack(side=TOP)
18777  RefTraceMenu = Menubutton(frameR, text="Reference Traces", width=17, style="W17.TButton")
18778  RefTraceMenu.menu = Menu(RefTraceMenu, tearoff = 0 )
18779  RefTraceMenu["menu"] = RefTraceMenu.menu
18780  RefTraceMenu.menu.add_command(label="-Take Snap Shot", command=BSnapShot)
18781  RefTraceMenu.menu.add_command(label="-Ref MUX trace-", foreground="blue", command=donothing)
18782  RefTraceMenu.menu.add_checkbutton(label='RMuxA', background=COLORtraceR2, variable=ShowRMA, command=UpdateTimeTrace)
18783  RefTraceMenu.menu.add_checkbutton(label='RMuxB', background=COLORtraceR6, variable=ShowRMB, command=UpdateTimeTrace)
18784  RefTraceMenu.menu.add_checkbutton(label='RMuxC', background=COLORtraceR7, variable=ShowRMC, command=UpdateTimeTrace)
18785  RefTraceMenu.menu.add_checkbutton(label='RMuxD', background=COLORtraceR4, variable=ShowRMD, command=UpdateTimeTrace)
18786  RefTraceMenu.pack(side=LEFT)
18787  #
18788  frameE = Frame(frameM)
18789  frameE.pack(side=TOP)
18790  muxenab = Checkbutton(frameE, text="Mux-Enb", variable=MuxEnb)
18791  muxenab.pack(side=LEFT)
18792  SyncButton = Checkbutton(frameE, compound=TOP, image=hipulseimg, variable=MuxSync, command=SyncImage)
18793  SyncButton.pack(side=LEFT)
18794  dismissbutton = Button(frameE, text="Dismiss", style="W8.TButton", command=DestroyMuxScreen)
18795  dismissbutton.pack(side=LEFT)
18796  frameF = Frame(frameM)
18797  frameF.pack(side=TOP)
18798  dmx = Checkbutton(frameF, text='Dual Mux Split I/O mode', variable=DualMuxMode, command=SetDualMuxMode)
18799  dmx.pack(side=LEFT)
18800  frameCH = Frame(frameM)
18801  frameCH.pack(side=TOP)
18802  altmx = Radiobutton(frameCH, text='Alternate Sweep', variable=ChopMuxMode, value=0, command=SetChopMuxMode)
18803  altmx.pack(side=LEFT)
18804  chopmx = Radiobutton(frameCH, text='Chop Sweep', variable=ChopMuxMode, value=1, command=SetChopMuxMode)
18805  chopmx.pack(side=LEFT)
18806  frameCT = Frame(frameM)
18807  frameCT.pack(side=TOP)
18808  # Chope Mode trigger drop-down
18809  ChopTrigMenu = Menubutton(frameCT, text="Chop Mode Trigger", width=17, style="W17.TButton")
18810  ChopTrigMenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
18811  ChopTrigMenu["menu"] = ChopTrigMenu.menu
18812  ChopTrigMenu.menu.add_command(label="-MUX Chan-", foreground="blue", command=donothing)
18813  ChopTrigMenu.menu.add_radiobutton(label="None", variable=ChopTrig, value=0) #, command=BAWGBModeLabel)
18814  ChopTrigMenu.menu.add_radiobutton(label="Mux A", variable=ChopTrig, value=1) #, command=BAWGBModeLabel)
18815  ChopTrigMenu.menu.add_radiobutton(label="Mux B", variable=ChopTrig, value=2) #, command=BAWGBModeLabel)
18816  ChopTrigMenu.menu.add_radiobutton(label="Mux C", variable=ChopTrig, value=3) #, command=BAWGBModeLabel)
18817  ChopTrigMenu.menu.add_radiobutton(label="Mux D", variable=ChopTrig, value=4) #, command=BAWGBModeLabel)
18818  ChopTrigMenu.pack(side=LEFT)
18819  #
18820  SaveMuxmenu = Menubutton(frameCT, text="Export csv", width=10, style="W17.TButton")
18821  SaveMuxmenu.menu = Menu(ChopTrigMenu, tearoff = 0 )
18822  SaveMuxmenu["menu"] = SaveMuxmenu.menu
18823  SaveMuxmenu.menu.add_command(label="Save Mux traces", command=BSaveMuxData)
18824  SaveMuxmenu.menu.add_command(label="Save single channel", command=BSaveChannelData)
18825  SaveMuxmenu.pack(side=LEFT)
18826  # Gray out main Channel B controls
18827  CHBlab.config(style="SGray.TButton")
18828  CHBofflab.config(style="SGray.TButton")
18829 
18830  #
18831  if ShowBallonHelp > 0:
18832  CHB_Alab_tip = CreateToolTip(CHB_Alab, 'Select CB-A vertical range/position axis to be used for markers and drawn color')
18833  CHB_Blab_tip = CreateToolTip(CHB_Blab, 'Select CB-B vertical range/position axis to be used for markers and drawn color')
18834  CHB_Clab_tip = CreateToolTip(CHB_Clab, 'Select CB-C vertical range/position axis to be used for markers and drawn color')
18835  CHB_Dlab_tip = CreateToolTip(CHB_Dlab, 'Select CB-D vertical range/position axis to be used for markers and drawn color')
18836  CHB_Aofflab_tip = CreateToolTip(CHB_Aofflab, 'Set CB-A position to DC average of signal')
18837  CHB_Bofflab_tip = CreateToolTip(CHB_Bofflab, 'Set CB-B position to DC average of signal')
18838  CHB_Cofflab_tip = CreateToolTip(CHB_Cofflab, 'Set CB-C position to DC average of signal')
18839  CHB_Dofflab_tip = CreateToolTip(CHB_Dofflab, 'Set CB-D position to DC average of signal')
18840  ChopTrigMenu_tip = CreateToolTip(ChopTrigMenu, 'Menu to Select Trigger Source')
18841  RefTraceMenu_tip = CreateToolTip(RefTraceMenu, 'Menu to Select Mux Reference Traces')
18842  SaveMuxmenu_tip = CreateToolTip(SaveMuxmenu, 'Menu to Export Mux Trace Data to .csv file')
18843 #
18845  global AWGAIOMode, AWGBIOMode, ShowC1_V, DualMuxMode, CHAlab, CHAofflab
18846  global CHB_Clab, CHB_Dlab, CHB_Cofflab, CHB_Dofflab, CHB_cbc, CHB_cbd
18847 
18848  if DualMuxMode.get() == 1:
18849  AWGAIOMode.set(1) # force awg A split I/O mode
18850  AWGBIOMode.set(1) # force awg B split I/O mode
18851  ShowC1_V.set(0) # force A voltage trace off
18852  CHB_cbc.config(text="CA-C")
18853  CHB_cbd.config(text="CA-D")
18854  CHB_Clab.config(text="CA-C V/Div")
18855  CHB_Dlab.config(text="CA-D V/Div")
18856  CHB_Cofflab.config(text="CA-C Pos")
18857  CHB_Dofflab.config(text="CA-D Pos")
18858  BAWGEnab() # update AWG settings
18859  # Gray out main Channel A controls
18860  CHAlab.config(style="SGray.TButton")
18861  CHAofflab.config(style="SGray.TButton")
18862  else:
18863  ShowC1_V.set(1) # force A voltage trace on
18864  CHB_cbc.config(text="CB-C")
18865  CHB_cbd.config(text="CB-D")
18866  CHB_Clab.config(text="CB-C V/Div")
18867  CHB_Dlab.config(text="CB-D V/Div")
18868  CHB_Cofflab.config(text="CB-C Pos")
18869  CHB_Dofflab.config(text="CB-D Pos")
18870  # Reset main Channel A control colors
18871  CHAlab.config(style="Rtrace1.TButton")
18872  CHAofflab.config(style="Rtrace1.TButton")
18873 #
18875  global ChopMuxMode, AWGAIOMode, AWGBIOMode, AWGAMode, AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry
18876  global AWGAPhaseEntry, SAMPLErate, ShowC1_V, ShowC2_V, TgInput
18877 
18878  if ChopMuxMode.get() > 0: # set AWG A to a square wave at 25 KHz 0.5 to 4.5 V, mode = SVMI_SPLIT
18879  AWGAIOMode.set(1) # force awg A split I/O mode
18880  AWGAMode.set(0) # force awg A mode to SVMI
18881  BAWGAModeLabel()
18882  AWGAShape.set(4) # force awg A to square shape
18883  AWGAAmplEntry.delete(0,"end")
18884  AWGAAmplEntry.insert(0,0.5) # force awg A Min value to 0.5 V
18885  AWGAOffsetEntry.delete(0,"end")
18886  AWGAOffsetEntry.insert(0,4.5) # force awg A Max value to 4.5 V
18887  AWGAFreqEntry.delete(0,"end")
18888  AWGAFreqEntry.insert(0,SAMPLErate/4) # force awg A Freg value to 25000 (1/4 base sample rate)
18889  AWGAPhaseEntry.delete(0,"end")
18890  AWGAPhaseEntry.insert(0,0) # force awg A Phase value to 0
18891  ReMakeAWGwaves()
18892  AWGBIOMode.set(1) # force awg A split I/O mode
18893  BAWGBModeLabel()
18894  ShowC1_V.set(0) # force A voltage trace off
18895  ShowC2_V.set(0) # force B voltage trace off
18896  TgInput.set(0) # force main Trigger source to none
18897  CHAlab.config(style="SGray.TButton")
18898  CHAofflab.config(style="SGray.TButton")
18899  else:
18900  CHAlab.config(style="Rtrace1.TButton")
18901  CHAofflab.config(style="Rtrace1.TButton")
18902 
18904  global MuxSync, hipulseimg, lowpulseimg, SyncButton
18905 
18906  if MuxSync.get() == 0:
18907  SyncButton.config(image=hipulseimg)
18908  else:
18909  SyncButton.config(image=lowpulseimg)
18910 
18912  global muxwindow, awgsync, MuxScreenStatus, CHAlab, CHAofflab, CHBlab, CHBofflab
18913  global ChopTrig, ChopMuxMode, MarkerScale
18914 
18915  MuxScreenStatus.set(0)
18916  awgsync.config(state=NORMAL)
18917  ChopMuxMode.set(0)
18918  ChopTrig.set(0)
18919  MarkerScale.set(0)
18920  # Reset main Channel B control colors
18921  CHBlab.config(style="Rtrace2.TButton")
18922  CHBofflab.config(style="Rtrace2.TButton")
18923  CHAlab.config(style="Rtrace1.TButton")
18924  CHAofflab.config(style="Rtrace1.TButton")
18925  muxwindow.destroy()
18926 #
18927 def BodeCaresize(event):
18928  global Bodeca, GRWBP, XOLBP, GRHBP, Y0TBP, CANVASwidthBP, CANVASheightBP, FontSize
18929 
18930  CANVASwidthBP = event.width - 4
18931  CANVASheightBP = event.height - 4
18932  GRWBP = CANVASwidthBP - (2 * X0LBP) # new grid width
18933  GRHBP = CANVASheightBP - int(10 * FontSize) # new grid height
18934  UpdateBodeAll()
18935 #
18937  global FStepSync, DevOne
18938 
18939  if FStepSync.get() == 0:
18940  Tval = devx.ctrl_transfer( 0xc0, 0x91, 0, 0, 0, 1, 100) # set PIO-0 to Z
18941  elif FStepSync.get() == 1:
18942  devx.ctrl_transfer( 0x40, 0x50, 0, 0, 0, 0, 100) # set PIO-0 to 0
18943  elif FStepSync.get() == 2:
18944  devx.ctrl_transfer( 0x40, 0x51, 0, 0, 0, 0, 100) # set PIO-0 to 1
18945 #
18947  global FSweepSync, DevOne
18948 
18949  if FSweepSync.get() == 0:
18950  Tval = devx.ctrl_transfer( 0xc0, 0x91, 1, 0, 0, 1, 100) # set PIO-1 to Z
18951  elif FSweepSync.get() == 1:
18952  devx.ctrl_transfer( 0x40, 0x50, 1, 0, 0, 0, 100) # set PIO-1 to 0
18953  elif FSweepSync.get() == 2:
18954  devx.ctrl_transfer( 0x40, 0x51, 1, 0, 0, 0, 100) # set PIO-1 to 1
18955 #
18957  global BDSweepFile, FileSweepFreq, FileSweepAmpl
18958 
18959  if BDSweepFile.get() > 0:
18960  # Read values from CVS file
18961  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent = bodewindow)
18962  try:
18963  CSVFile = open(filename)
18964  csv_f = csv.reader(CSVFile)
18965  FileSweepFreq = []
18966  FileSweepAmpl = []
18967  for row in csv_f:
18968  try:
18969  FileSweepFreq.append(float(row[0]))
18970  FileSweepAmpl.append(float(row[1]))
18971  except:
18972  print( 'skipping non-numeric row')
18973  FileSweepFreq = numpy.array(FileSweepFreq)
18974  FileSweepAmpl = numpy.array(FileSweepAmpl)
18975  MaxAmpl = numpy.amax(FileSweepAmpl)
18976  NormAmpl = MaxAmpl
18977  s = askstring("Normalize Max Amplitude", "Max Amplitude = " + str(MaxAmpl) + "\n\n Enter New Max value:\n in dB", parent = bodewindow)
18978  if (s == None): # If Cancel pressed, then None
18979  return()
18980  try: # Error if for example no numeric characters or OK pressed without input (s = "")
18981  v = int(s)
18982  except:
18983  s = "error"
18984 
18985  if s != "error":
18986  NormAmpl = MaxAmpl - v
18987  else:
18988  NormAmpl = MaxAmpl
18989  FileSweepAmpl = FileSweepAmpl - NormAmpl # normalize max amplitude to requested dBV
18990  CSVFile.close()
18991  StopBodeEntry.delete(0,"end")
18992  StopBodeEntry.insert(0,FileSweepFreq[len(FileSweepFreq)-1])
18993  StartBodeEntry.delete(0,"end")
18994  StartBodeEntry.insert(0,FileSweepFreq[0])
18995  SweepStepBodeEntry.delete(0,"end")
18996  SweepStepBodeEntry.insert(0,len(FileSweepFreq))
18997  except:
18998  showwarning("WARNING","No such file found or wrong format!", parent = bodewindow)
18999 #
19000 # ========== Make Bode Plot Window =============
19002  global logo, SmoothCurvesBP, CutDC, bodewindow, SWRev
19003  global CANVASwidthBP, CANVASheightBP, FFTwindow, CutDC, AWGAMode, AWGAShape, AWGBMode
19004  global ShowCA_VdB, ShowCA_P, ShowCB_VdB, ShowCB_P, ShowMarkerBP, BodeDisp, RelPhaseCenter
19005  global ShowCA_RdB, ShowCA_RP, ShowCB_RdB, ShowCB_RP, ShowMathBP, ShowRMathBP, PhCenBodeEntry
19006  global BPSweepMode, BPSweepCont, Bodeca, BodeScreenStatus, RevDate, SweepStepBodeEntry
19007  global HScaleBP, StopBodeEntry, StartBodeEntry, ShowBPCur, ShowBdBCur, BPCursor, BdBCursor
19008  global GRWBP, GRHBP, X0LBP, FStepSync, FSweepSync, BDSweepFile, MinigenScreenStatus
19009  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle, ImpedanceCenter, ImCenBodeEntry
19010  global Show_RseriesRef, Show_XseriesRef, Show_MagnitudeRef, Show_AngleRef
19011  global FrameRefief, BorderSize, LocalLanguage
19012  global sbode_tip, rbode_tip, bd3_tip, bd4_tip, bd5_tip, bd6_tip, bd7_tip, bd8_tip, bodismiss1button_tip
19013  global bstopfreqlab, bstartfreqlab, ImCenlab, BPhCenlab
19014 
19015  if BodeScreenStatus.get() == 0:
19016  BodeScreenStatus.set(1)
19017  BodeDisp.set(1)
19018  BodeCheckBox()
19019  CANVASwidthBP = GRWBP + 2 * X0LBP # The Bode canvas width
19020  CANVASheightBP = GRHBP + 80 # The ode canvas height
19021  CutDC.set(1) # set to remove DC
19022  AWGAMode.set(0) # Set AWG A to SVMI
19023  AWGAShape.set(1) # Set Shape to Sine
19024  AWGBMode.set(2) # Set AWG B to Hi-Z
19025  bodewindow = Toplevel()
19026  bodewindow.title("Bode Plotter " + SWRev + RevDate)
19027  bodewindow.protocol("WM_DELETE_WINDOW", DestroyBodeScreen)
19028  frame2bp = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19029  frame2bp.pack(side=RIGHT, expand=NO, fill=BOTH)
19030 
19031  frame2b = Frame(bodewindow, borderwidth=BorderSize, relief=FrameRefief)
19032  frame2b.pack(side=TOP, expand=YES, fill=BOTH)
19033 
19034  Bodeca = Canvas(frame2b, width=CANVASwidthBP, height=CANVASheightBP, background=COLORcanvas, cursor='cross')
19035  Bodeca.bind('<Configure>', BodeCaresize)
19036  Bodeca.bind('<1>', onCanvasBodeLeftClick)
19037  Bodeca.bind('<3>', onCanvasBodeRightClick)
19038  Bodeca.bind("<Up>", onCanvasUpArrow)
19039  Bodeca.bind("<Down>", onCanvasDownArrow)
19040  Bodeca.bind("<Left>", onCanvasLeftArrow)
19041  Bodeca.bind("<Right>", onCanvasRightArrow)
19042  Bodeca.bind("<space>", onCanvasSpaceBar)
19043  Bodeca.bind("1", onCanvasBdOne)
19044  Bodeca.bind("2", onCanvasBdTwo)
19045  Bodeca.bind("3", onCanvasBdThree)
19046  Bodeca.bind("4", onCanvasBdFour)
19047  Bodeca.bind("5", onCanvasBdFive)
19048  Bodeca.bind("6", onCanvasBdSix)
19049  Bodeca.bind("7", onCanvasBdSeven)
19050  Bodeca.bind("8", onCanvasBdEight)
19051  Bodeca.bind("9", onCanvasBdNine)
19052  Bodeca.bind("0", onCanvasBdZero)
19053  Bodeca.bind("f", onCanvasShowBPcur)
19054  Bodeca.bind("d", onCanvasShowBdBcur)
19055  Bodeca.bind("h", onCanvasShowPdBcur)
19056  Bodeca.bind("s", onCanvasBdSnap)
19057  Bodeca.pack(side=TOP, expand=YES, fill=BOTH)
19058 
19059  # right side drop down menu buttons
19060  dropmenu = Frame( frame2bp )
19061  dropmenu.pack(side=TOP)
19062  # File menu
19063  BodeFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
19064  BodeFilemenu.menu = Menu(BodeFilemenu, tearoff = 0 )
19065  BodeFilemenu["menu"] = BodeFilemenu.menu
19066  BodeFilemenu.menu.add_command(label="Save Config", command=BSaveConfigBP)
19067  BodeFilemenu.menu.add_command(label="Load Config", command=BLoadConfigBP)
19068  BodeFilemenu.menu.add_command(label="Run Script", command=RunScript)
19069  BodeFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenBP)
19070  BodeFilemenu.menu.add_command(label="Save Data", command=BCSVfile)
19071  BodeFilemenu.pack(side=LEFT, anchor=W)
19072  #
19073  BodeOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
19074  BodeOptionmenu.menu = Menu(BodeOptionmenu, tearoff = 0 )
19075  BodeOptionmenu["menu"] = BodeOptionmenu.menu
19076  BodeOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19077  BodeOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesBP)
19078  BodeOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
19079  BodeOptionmenu.menu.add_command(label="Store trace (s)", command=BSTOREtraceBP)
19080  BodeOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19081  BodeOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19082  BodeOptionmenu.menu.add_command(label="-Step Sync Pulse-", command=donothing)
19083  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FStepSync, value=0, command=BStepSync)
19084  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FStepSync, value=1, command=BStepSync)
19085  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FStepSync, value=2, command=BStepSync)
19086  BodeOptionmenu.menu.add_command(label="-Sweep Sync Pulse-", command=donothing)
19087  BodeOptionmenu.menu.add_radiobutton(label='None', variable=FSweepSync, value=0, command=BSweepSync)
19088  BodeOptionmenu.menu.add_radiobutton(label='Rising', variable=FSweepSync, value=1, command=BSweepSync)
19089  BodeOptionmenu.menu.add_radiobutton(label='Falling', variable=FSweepSync, value=2, command=BSweepSync)
19090  BodeOptionmenu.pack(side=LEFT, anchor=W)
19091  #
19092  RUNframe = Frame( frame2bp )
19093  RUNframe.pack(side=TOP)
19094  rbode = Button(RUNframe, text="Run", style="Run.TButton", command=BStartBP)
19095  rbode.pack(side=LEFT)
19096  sbode = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopBP)
19097  sbode.pack(side=LEFT)
19098  #
19099  BodeFFTwindmenu = Menubutton(frame2bp, text="FFTwindow", style="W11.TButton")
19100  BodeFFTwindmenu.menu = Menu(BodeFFTwindmenu, tearoff = 0 )
19101  BodeFFTwindmenu["menu"] = BodeFFTwindmenu.menu
19102  BodeFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
19103  BodeFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
19104  BodeFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
19105  BodeFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
19106  BodeFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
19107  BodeFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
19108  BodeFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
19109  BodeFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
19110  BodeFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
19111  BodeFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
19112  BodeFFTwindmenu.pack(side=TOP)
19113  #
19114  tracemenu = Frame( frame2bp )
19115  tracemenu.pack(side=TOP)
19116  # Curves menu
19117  # Show channels menu
19118  BodeShowmenu = Menubutton(tracemenu, text="Curves", style="W7.TButton")
19119  BodeShowmenu.menu = Menu(BodeShowmenu, tearoff = 0 )
19120  BodeShowmenu["menu"] = BodeShowmenu.menu
19121  BodeShowmenu.menu.add_command(label="-Show-", command=donothing)
19122  BodeShowmenu.menu.add_command(label="All", command=BShowCurvesAllBP)
19123  BodeShowmenu.menu.add_command(label="None", command=BShowCurvesNoneBP)
19124  BodeShowmenu.menu.add_checkbutton(label='CA-dBV (1)', variable=ShowCA_VdB, command=UpdateBodeAll)
19125  BodeShowmenu.menu.add_checkbutton(label='CB-dBV (2)', variable=ShowCB_VdB, command=UpdateBodeAll)
19126  BodeShowmenu.menu.add_checkbutton(label='Phase A-B (3)', variable=ShowCA_P, command=UpdateBodeAll)
19127  BodeShowmenu.menu.add_checkbutton(label='Phase B-A (4)', variable=ShowCB_P, command=UpdateBodeAll)
19128  BodeShowmenu.menu.add_command(label="-Math-", command=donothing)
19129  BodeShowmenu.menu.add_radiobutton(label='None (0)', variable=ShowMathBP, value=0, command=UpdateBodeAll)
19130  BodeShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB (9)', variable=ShowMathBP, value=1, command=UpdateBodeAll)
19131  BodeShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB (8)', variable=ShowMathBP, value=2, command=UpdateBodeAll)
19132  BodeShowmenu.menu.add_command(label="-Impedance-", command=donothing)
19133  BodeShowmenu.menu.add_checkbutton(label='Series R', variable=Show_Rseries, command=UpdateBodeAll)
19134  BodeShowmenu.menu.add_checkbutton(label='Series X', variable=Show_Xseries, command=UpdateBodeAll)
19135  BodeShowmenu.menu.add_checkbutton(label='Series Mag', variable= Show_Magnitude, command=UpdateBodeAll)
19136  BodeShowmenu.menu.add_checkbutton(label='Series Ang', variable=Show_Angle, command=UpdateBodeAll)
19137  BodeShowmenu.menu.add_separator()
19138  BodeShowmenu.menu.add_checkbutton(label='RA-dBV (6)', variable=ShowCA_RdB, command=UpdateBodeAll)
19139  BodeShowmenu.menu.add_checkbutton(label='RB-dBV (7)', variable=ShowCB_RdB, command=UpdateBodeAll)
19140  BodeShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowCA_RP, command=UpdateBodeAll)
19141  BodeShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowCB_RP, command=UpdateBodeAll)
19142  BodeShowmenu.menu.add_checkbutton(label='Math', variable=ShowRMathBP, command=UpdateBodeAll)
19143  BodeShowmenu.menu.add_checkbutton(label='Ref Series R', variable=Show_RseriesRef, command=UpdateBodeAll)
19144  BodeShowmenu.menu.add_checkbutton(label='Ref Series X', variable=Show_XseriesRef, command=UpdateBodeAll)
19145  BodeShowmenu.menu.add_checkbutton(label='Ref Series Mag', variable=Show_MagnitudeRef, command=UpdateBodeAll)
19146  BodeShowmenu.menu.add_checkbutton(label='Ref Series Ang', variable=Show_AngleRef, command=UpdateBodeAll)
19147  BodeShowmenu.pack(side=LEFT, anchor=W)
19148  #
19149  BodeMarkmenu = Menubutton(tracemenu, text="Cursors", style="W7.TButton")
19150  BodeMarkmenu.menu = Menu(BodeMarkmenu, tearoff = 0 )
19151  BodeMarkmenu["menu"] = BodeMarkmenu.menu
19152  BodeMarkmenu.menu.add_command(label="-Cursors&Markers-", command=donothing)
19153  BodeMarkmenu.menu.add_checkbutton(label='Marker (5)', variable=ShowMarkerBP, command=UpdateBodeAll)
19154  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor', variable=ShowBPCur)
19155  BodeMarkmenu.menu.add_checkbutton(label='dB Cursor', variable=ShowBdBCur)
19156  BodeMarkmenu.menu.add_radiobutton(label='Cursor Off', variable=ShowBdBCur, value=0)
19157  BodeMarkmenu.menu.add_radiobutton(label='dB Cursor (d)', variable=ShowBdBCur, value=1)
19158  BodeMarkmenu.menu.add_radiobutton(label='Phase Cursor (h)', variable=ShowBdBCur, value=2)
19159  BodeMarkmenu.menu.add_checkbutton(label='Freq Cursor (f)', variable=ShowBPCur)
19160  BodeMarkmenu.pack(side=LEFT, anchor=W)
19161  #
19162  # Horz Scale
19163  HzScale = Frame( frame2bp )
19164  HzScale.pack(side=TOP)
19165  brb1 = Radiobutton(HzScale, text="Lin F", variable=HScaleBP, value=0, command=UpdateBodeTrace )
19166  brb1.pack(side=LEFT)
19167  brb2 = Radiobutton(HzScale, text="Log F", variable=HScaleBP, value=1, command=UpdateBodeTrace )
19168  brb2.pack(side=LEFT)
19169 
19170  DBrange = Frame( frame2bp )
19171  DBrange.pack(side=TOP)
19172  bd3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2BP)
19173  bd3.pack(side=LEFT)
19174  bd4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1BP)
19175  bd4.pack(side=LEFT)
19176 
19177  LVBrange = Frame( frame2bp )
19178  LVBrange.pack(side=TOP)
19179  bd5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4BP)
19180  bd5.pack(side=LEFT)
19181  bd6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3BP)
19182  bd6.pack(side=LEFT)
19183 
19184  LVSrange = Frame( frame2bp )
19185  LVSrange.pack(side=TOP)
19186  bd7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2BP)
19187  bd7.pack(side=LEFT)
19188  bd8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1BP)
19189  bd8.pack(side=LEFT)
19190 
19191  PhaseCenter = Frame( frame2bp )
19192  PhaseCenter.pack(side=TOP)
19193  BPhCenlab = Label(PhaseCenter, text="Center Phase on")
19194  BPhCenlab.pack(side=LEFT)
19195  PhCenBodeEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
19196  PhCenBodeEntry.bind('<Return>', onTextKey)
19197  PhCenBodeEntry.bind('<MouseWheel>', onTextScroll)
19198  PhCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19199  PhCenBodeEntry.bind("<Button-5>", onTextScroll)
19200  PhCenBodeEntry.bind('<Key>', onTextKey)
19201  PhCenBodeEntry.pack(side=LEFT)
19202  PhCenBodeEntry.delete(0,"end")
19203  PhCenBodeEntry.insert(0,RelPhaseCenter.get())
19204  #
19205  ImpedCenter = Frame( frame2bp )
19206  ImpedCenter.pack(side=TOP)
19207  ImCenlab = Label(ImpedCenter, text="Center Imped on")
19208  ImCenlab.pack(side=LEFT)
19209  ImCenBodeEntry = Entry(ImpedCenter, width=5, cursor='double_arrow')
19210  ImCenBodeEntry.bind('<Return>', onTextKey)
19211  ImCenBodeEntry.bind('<MouseWheel>', onTextScroll)
19212  ImCenBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19213  ImCenBodeEntry.bind("<Button-5>", onTextScroll)
19214  ImCenBodeEntry.bind('<Key>', onTextKey)
19215  ImCenBodeEntry.pack(side=LEFT)
19216  ImCenBodeEntry.delete(0,"end")
19217  ImCenBodeEntry.insert(0,ImpedanceCenter.get())
19218  # sweep generator mode menu buttons
19219  FSweepmenu = Label(frame2bp, text="-Sweep Gen-", style="A10B.TLabel")
19220  FSweepmenu.pack(side=TOP)
19221 
19222  Frange1 = Frame( frame2bp )
19223  Frange1.pack(side=TOP)
19224  bstartfreqlab = Label(Frange1, text="Start Freq")
19225  bstartfreqlab.pack(side=LEFT)
19226  StartBodeEntry = Entry(Frange1, width=5, cursor='double_arrow')
19227  StartBodeEntry.bind('<Return>', onTextKey)
19228  StartBodeEntry.bind('<MouseWheel>', onTextScroll)
19229  StartBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19230  StartBodeEntry.bind("<Button-5>", onTextScroll)
19231  StartBodeEntry.bind('<Key>', onTextKey)
19232  StartBodeEntry.pack(side=LEFT)
19233  StartBodeEntry.delete(0,"end")
19234  StartBodeEntry.insert(0,10)
19235 
19236  Frange2 = Frame( frame2bp )
19237  Frange2.pack(side=TOP)
19238  bstopfreqlab = Label(Frange2, text="Stop Freq")
19239  bstopfreqlab.pack(side=LEFT)
19240  StopBodeEntry = Entry(Frange2, width=5, cursor='double_arrow')
19241  StopBodeEntry.bind('<Return>', onTextKey)
19242  StopBodeEntry.bind('<MouseWheel>', onStopBodeScroll)
19243  StopBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19244  StopBodeEntry.bind("<Button-5>", onTextScroll)
19245  StopBodeEntry.bind('<Key>', onTextKey)
19246  StopBodeEntry.pack(side=LEFT)
19247  StopBodeEntry.delete(0,"end")
19248  StopBodeEntry.insert(0,10000)
19249 
19250  sgrb1 = Radiobutton(frame2bp, text='None', variable=FSweepMode, value=0)
19251  sgrb1.pack(side=TOP)
19252  Frange4 = Frame( frame2bp )
19253  Frange4.pack(side=TOP)
19254  sgrb2 = Radiobutton(Frange4, text='CH-A', variable=FSweepMode, value=1)
19255  sgrb2.pack(side=LEFT)
19256  sgrb3 = Radiobutton(Frange4, text='CH-B', variable=FSweepMode, value=2)
19257  sgrb3.pack(side=LEFT)
19258  if MinigenScreenStatus.get() > 0:
19259  sgrb1 = Radiobutton(frame2bp, text='MinGen', variable=FSweepMode, value=3)
19260  sgrb1.pack(side=TOP)
19261  ffcb = Checkbutton(frame2bp, text='Sweep From File', variable=BDSweepFile, command=BDSweepFromFile)
19262  ffcb.pack(side=TOP)
19263  Frange3 = Frame( frame2bp )
19264  Frange3.pack(side=TOP)
19265  sweepsteplab = Label(Frange3, text="Sweep Steps")
19266  sweepsteplab.pack(side=LEFT)
19267  SweepStepBodeEntry = Entry(Frange3, width=5, cursor='double_arrow')
19268  SweepStepBodeEntry.bind('<Return>', onTextKey)
19269  SweepStepBodeEntry.bind('<MouseWheel>', onTextScroll)
19270  SweepStepBodeEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19271  SweepStepBodeEntry.bind("<Button-5>", onTextScroll)
19272  SweepStepBodeEntry.bind('<Key>', onTextKey)
19273  SweepStepBodeEntry.pack(side=LEFT)
19274  SweepStepBodeEntry.delete(0,"end")
19275  SweepStepBodeEntry.insert(0,100)
19276 
19277  sgrb5 = Radiobutton(frame2bp, text='Single', variable=FSweepCont, value=0)
19278  sgrb5.pack(side=TOP)
19279  sgrb6 = Radiobutton(frame2bp, text='Continuous', variable=FSweepCont, value=1)
19280  sgrb6.pack(side=TOP)
19281  Plotsframe = Frame( frame2bp )
19282  Plotsframe.pack(side=TOP)
19283  nyquistplotbutton = Button(Plotsframe, text="Polar Plot", style="W9.TButton", command=MakeNyquistPlot)
19284  nyquistplotbutton.pack(side=LEFT)
19285  nicholsplotbutton = Button(Plotsframe, text="Rect Plot", style="W8.TButton", command=MakeNicPlot)
19286  nicholsplotbutton.pack(side=LEFT)
19287  bodismiss1button = Button(frame2bp, text="Dismiss", style="W8.TButton", command=DestroyBodeScreen)
19288  bodismiss1button.pack(side=TOP)
19289 
19290  ADI2 = Label(frame2bp, image=logo, anchor= "sw", compound="top") #, height=49, width=116
19291  ADI2.pack(side=TOP)
19292  if ShowBallonHelp > 0:
19293  sbode_tip = CreateToolTip(sbode, 'Stop acquiring data')
19294  rbode_tip = CreateToolTip(rbode, 'Start acquiring data')
19295  bd3_tip = CreateToolTip(bd3, 'Increase number of dB/Div')
19296  bd4_tip = CreateToolTip(bd4, 'Decrease number of dB/Div')
19297  bd5_tip = CreateToolTip(bd5, 'Increase Ref Level by 10 dB')
19298  bd6_tip = CreateToolTip(bd6, 'Decrease Ref Level by 10 dB')
19299  bd7_tip = CreateToolTip(bd7, 'Increase Ref Level by 1 dB')
19300  bd8_tip = CreateToolTip(bd8, 'Decrease Ref Level by 1 dB')
19301  bodismiss1button_tip = CreateToolTip(bodismiss1button, 'Dismiss Bode Plot window')
19302  if LocalLanguage != "English":
19303  BLoadConfig(LocalLanguage) # load local language configuration
19304 #
19306  global bodewindow, BodeScreenStatus, ca, FSweepMode
19307 
19308  BodeScreenStatus.set(0)
19309  FSweepMode.set(0)
19310  BodeDisp.set(0)
19311  BodeCheckBox()
19312  bodewindow.destroy()
19313  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
19314 #
19315 def FreqCaresize(event):
19316  global Freqca, GRWF, XOLF, GRHF, Y0TF, CANVASwidthF, CANVASheightF, FontSize
19317 
19318  CANVASwidthF = event.width - 4
19319  CANVASheightF = event.height - 4
19320  GRWF = CANVASwidthF - 10 - (2 * X0LF) # new grid width
19321  GRHF = CANVASheightF - int(10 * FontSize) # new grid height
19322  UpdateFreqAll()
19323 #
19324 # ================ Make spectrum sub window ==========================
19326  global logo, SmoothCurvesSA, CutDC, SingleShotSA, FFTwindow, freqwindow, SmoothCurvesSA
19327  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, ShowMarker, FreqDisp, ShowAWGASA
19328  global ShowRA_VdB, ShowRA_P, ShowRB_VdB, ShowRB_P, ShowMathSA, SWRev, SingleShotSA, ShowAWGBSA
19329  global ShowRMath, FSweepMode, FSweepCont, Freqca, SpectrumScreenStatus, RevDate, AWGShowAdvanced
19330  global HScale, StopFreqEntry, StartFreqEntry, ShowFCur, ShowdBCur, FCursor, dBCursor
19331  global CANVASwidthF, GRWF, X0LF, CANVASheightF, GRHF, FontSize, PhCenFreqEntry, RelPhaseCenter
19332  global FrameRefief, BorderSize, LocalLanguage, SAVScale, SAVPSD, SAvertmaxEntry, SAvertminEntry
19333  global sb_tip, rb_tip, bless_tip, bmore_tip, b3_tip, b4_tip, b5_tip, b6_tip, b7_tip, b8_tip, sadismiss1button_tip
19334  global SAMagdiv, SAVScale, SAvertmaxEntry, SAvertminEntry, SAVPSD
19335 
19336  if SpectrumScreenStatus.get() == 0:
19337  SpectrumScreenStatus.set(1)
19338  FreqDisp.set(1)
19339  FreqCheckBox()
19340  CANVASwidthF = GRWF + 10 + 2 * X0LF # The spectrum canvas width
19341  CANVASheightF = GRHF + int(10 * FontSize) # 80 The spectrum canvas height
19342  freqwindow = Toplevel()
19343  freqwindow.title("Spectrum Analyzer " + SWRev + RevDate)
19344  freqwindow.protocol("WM_DELETE_WINDOW", DestroySpectrumScreen)
19345  frame2fr = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
19346  frame2fr.pack(side=RIGHT, expand=NO, fill=BOTH)
19347 
19348  frame2f = Frame(freqwindow, borderwidth=BorderSize, relief=FrameRefief)
19349  frame2f.pack(side=TOP, expand=YES, fill=BOTH)
19350 
19351  Freqca = Canvas(frame2f, width=CANVASwidthF, height=CANVASheightF, background=COLORcanvas, cursor='cross')
19352  Freqca.bind('<Configure>', FreqCaresize)
19353  Freqca.bind('<1>', onCanvasFreqLeftClick)
19354  Freqca.bind('<3>', onCanvasFreqRightClick)
19355  Freqca.bind("<Up>", onCanvasUpArrow)
19356  Freqca.bind("<Down>", onCanvasDownArrow)
19357  Freqca.bind("<Left>", onCanvasLeftArrow)
19358  Freqca.bind("<Right>", onCanvasRightArrow)
19359  Freqca.bind("<space>", onCanvasSpaceBar)
19360  Freqca.bind("1", onCanvasSAOne)
19361  Freqca.bind("2", onCanvasSATwo)
19362  Freqca.bind("3", onCanvasSAThree)
19363  Freqca.bind("4", onCanvasSAFour)
19364  Freqca.bind("5", onCanvasSAFive)
19365  Freqca.bind("6", onCanvasSASix)
19366  Freqca.bind("7", onCanvasSASeven)
19367  Freqca.bind("8", onCanvasSAEight)
19368  Freqca.bind("9", onCanvasSANine)
19369  Freqca.bind("0", onCanvasSAZero)
19370  Freqca.bind("a", onCanvasSAAverage)
19371  Freqca.bind("n", onCanvasSANormal)
19372  Freqca.bind("p", onCanvasSAPeak)
19373  Freqca.bind("r", onCanvasSAReset)
19374  Freqca.bind("f", onCanvasShowFcur)
19375  Freqca.bind("d", onCanvasShowdBcur)
19376  Freqca.bind("h", onCanvasShowPcur)
19377  Freqca.bind("s", onCanvasSASnap)
19378  Freqca.pack(side=TOP, expand=YES, fill=BOTH)
19379  # right side drop down menu buttons
19380  dropmenu = Frame( frame2fr )
19381  dropmenu.pack(side=TOP)
19382  # File menu
19383  SAFilemenu = Menubutton(dropmenu, text="File", style="W5.TButton")
19384  SAFilemenu.menu = Menu(SAFilemenu, tearoff = 0 )
19385  SAFilemenu["menu"] = SAFilemenu.menu
19386  SAFilemenu.menu.add_command(label="Save Config", command=BSaveConfigSA)
19387  SAFilemenu.menu.add_command(label="Load Config", command=BLoadConfigSA)
19388  SAFilemenu.menu.add_command(label="Run Script", command=RunScript)
19389  SAFilemenu.menu.add_command(label="Save Screen", command=BSaveScreenSA)
19390  SAFilemenu.menu.add_command(label="Save Data", command=STOREcsvfile)
19391  SAFilemenu.pack(side=LEFT, anchor=W)
19392  #
19393  SAOptionmenu = Menubutton(dropmenu, text="Options", style="W8.TButton")
19394  SAOptionmenu.menu = Menu(SAOptionmenu, tearoff = 0 )
19395  SAOptionmenu["menu"] = SAOptionmenu.menu
19396  SAOptionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
19397  SAOptionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
19398  SAOptionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurvesSA)
19399  SAOptionmenu.menu.add_checkbutton(label='Cut-DC', variable=CutDC)
19400  SAOptionmenu.menu.add_command(label="Store trace [s]", command=BSTOREtraceSA)
19401  SAOptionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
19402  SAOptionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
19403  SAOptionmenu.pack(side=LEFT, anchor=W)
19404  #
19405  RUNframe = Frame( frame2fr )
19406  RUNframe.pack(side=TOP)
19407  sarb = Button(RUNframe, text="Run", style="Run.TButton", command=BStartSA)
19408  sarb.pack(side=LEFT)
19409  sasb = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStopSA)
19410  sasb.pack(side=LEFT)
19411  #
19412  Modeframe = Frame( frame2fr )
19413  Modeframe.pack(side=TOP)
19414  Modemenu = Menubutton(Modeframe, text="Mode", style="W5.TButton")
19415  Modemenu.menu = Menu(Modemenu, tearoff = 0 )
19416  Modemenu["menu"] = Modemenu.menu
19417  Modemenu.menu.add_command(label="Normal mode [n]", command=BNormalmode)
19418  Modemenu.menu.add_command(label="Peak hold [p]", command=BPeakholdmode)
19419  Modemenu.menu.add_command(label="Average [a]", command=BAveragemode)
19420  Modemenu.menu.add_command(label="Reset Average [r]", command=BResetFreqAvg)
19421  Modemenu.menu.add_checkbutton(label='SingleShot', variable=SingleShotSA)
19422  Modemenu.pack(side=LEFT)
19423  #
19424  SAFFTwindmenu = Menubutton(Modeframe, text="FFTwindow", style="W11.TButton")
19425  SAFFTwindmenu.menu = Menu(SAFFTwindmenu, tearoff = 0 )
19426  SAFFTwindmenu["menu"] = SAFFTwindmenu.menu
19427  SAFFTwindmenu.menu.add_radiobutton(label='Rectangular window (B=1)', variable=FFTwindow, value=0)
19428  SAFFTwindmenu.menu.add_radiobutton(label='Cosine window (B=1.24)', variable=FFTwindow, value=1)
19429  SAFFTwindmenu.menu.add_radiobutton(label='Triangular window (B=1.33)', variable=FFTwindow, value=2)
19430  SAFFTwindmenu.menu.add_radiobutton(label='Hann window (B=1.5)', variable=FFTwindow, value=3)
19431  SAFFTwindmenu.menu.add_radiobutton(label='Blackman window (B=1.73)', variable=FFTwindow, value=4)
19432  SAFFTwindmenu.menu.add_radiobutton(label='Nuttall window (B=2.02)', variable=FFTwindow, value=5)
19433  SAFFTwindmenu.menu.add_radiobutton(label='Flat top window (B=3.77)', variable=FFTwindow, value=6)
19434  SAFFTwindmenu.menu.add_radiobutton(label='User Defined window', variable=FFTwindow, value=7)
19435  SAFFTwindmenu.menu.add_command(label="Enter User function", command=BUserFFTwindow)
19436  SAFFTwindmenu.menu.add_radiobutton(label='FFT Window from file', variable=FFTwindow, value=8, command=BFileFFTwindow)
19437  SAFFTwindmenu.pack(side=LEFT)
19438  #
19439  SamplesMenu = Frame( frame2fr )
19440  SamplesMenu.pack(side=TOP)
19441  bless = Button(SamplesMenu, text="-Samples", style="W8.TButton", command=Bsamples1)
19442  bless.pack(side=LEFT)
19443  bmore = Button(SamplesMenu, text="+Samples", style="W8.TButton", command=Bsamples2)
19444  bmore.pack(side=LEFT)
19445  #
19446  # Show channels menu
19447  #
19448  MarkersMenu = Frame( frame2fr )
19449  MarkersMenu.pack(side=TOP)
19450  SAShowmenu = Menubutton(MarkersMenu, text="Curves", style="W7.TButton")
19451  SAShowmenu.menu = Menu(SAShowmenu, tearoff = 0 )
19452  SAShowmenu["menu"] = SAShowmenu.menu
19453  SAShowmenu.menu.add_command(label="-Show-", command=donothing)
19454  SAShowmenu.menu.add_command(label="All", command=BShowCurvesAllSA)
19455  SAShowmenu.menu.add_command(label="None", command=BShowCurvesNoneSA)
19456  SAShowmenu.menu.add_checkbutton(label='CA-dBV [1]', variable=ShowC1_VdB, command=UpdateFreqAll)
19457  SAShowmenu.menu.add_checkbutton(label='CB-dBV [2]', variable=ShowC2_VdB, command=UpdateFreqAll)
19458  SAShowmenu.menu.add_checkbutton(label='Phase A-B [3]', variable=ShowC1_P, command=UpdateFreqAll)
19459  SAShowmenu.menu.add_checkbutton(label='Phase B-A [4]', variable=ShowC2_P, command=UpdateFreqAll)
19460  SAShowmenu.menu.add_command(label="-Math-", command=donothing)
19461  SAShowmenu.menu.add_radiobutton(label='None [0]', variable=ShowMathSA, value=0, command=UpdateFreqAll)
19462  SAShowmenu.menu.add_radiobutton(label='CA-dB - CB-dB [9]', variable=ShowMathSA, value=1, command=UpdateFreqAll)
19463  SAShowmenu.menu.add_radiobutton(label='CB-dB - CA-dB [8]', variable=ShowMathSA, value=2, command=UpdateFreqAll)
19464  if AWGShowAdvanced.get() > 0:
19465  SAShowmenu.menu.add_command(label="-AWG-", command=donothing)
19466  SAShowmenu.menu.add_checkbutton(label='AWG A', variable=ShowAWGASA, command=UpdateFreqAll)
19467  SAShowmenu.menu.add_checkbutton(label='AWG B', variable=ShowAWGBSA, command=UpdateFreqAll)
19468  SAShowmenu.menu.add_command(label="-Ref Trace-", command=donothing)
19469  SAShowmenu.menu.add_checkbutton(label='RA-dBV [6]', variable=ShowRA_VdB, command=UpdateFreqAll)
19470  SAShowmenu.menu.add_checkbutton(label='RB-dBV [7]', variable=ShowRB_VdB, command=UpdateFreqAll)
19471  SAShowmenu.menu.add_checkbutton(label='RPhase A-B', variable=ShowRA_P, command=UpdateFreqAll)
19472  SAShowmenu.menu.add_checkbutton(label='RPhase B-A', variable=ShowRB_P, command=UpdateFreqAll)
19473  SAShowmenu.menu.add_checkbutton(label='Ref Math', variable=ShowRMath, command=UpdateFreqAll)
19474  SAShowmenu.pack(side=LEFT)
19475  SACursormenu = Menubutton(MarkersMenu, text="Cursors", style="W7.TButton")
19476  SACursormenu.menu = Menu(SACursormenu, tearoff = 0 )
19477  SACursormenu["menu"] = SACursormenu.menu
19478  SACursormenu.menu.add_command(label="-Marker-", command=donothing)
19479  SACursormenu.menu.add_radiobutton(label='Markers Off', variable=ShowMarker, value=0, command=UpdateFreqAll)
19480  SACursormenu.menu.add_radiobutton(label='Markers [5]', variable=ShowMarker, value=1, command=UpdateFreqAll)
19481  SACursormenu.menu.add_radiobutton(label='Delta Markers', variable=ShowMarker, value=2, command=UpdateFreqAll)
19482  SACursormenu.menu.add_command(label="-Cursors-", command=donothing)
19483  SACursormenu.menu.add_radiobutton(label='Cursor Off', variable=ShowdBCur, value=0)
19484  SACursormenu.menu.add_radiobutton(label='dB Cursor [d]', variable=ShowdBCur, value=1)
19485  #SACursormenu.menu.add_radiobutton(label='Phase Cursor [h]', variable=ShowdBCur, value=2)
19486  SACursormenu.menu.add_checkbutton(label='Freq Cursor [f]', variable=ShowFCur)
19487  SACursormenu.pack(side=LEFT)
19488  # HScale
19489  Frange1 = Frame( frame2fr )
19490  Frange1.pack(side=TOP)
19491  startfreqlab = Label(Frange1, text="Startfreq")
19492  startfreqlab.pack(side=LEFT)
19493  StartFreqEntry = Entry(Frange1, width=5, cursor='double_arrow')
19494  StartFreqEntry.bind('<Return>', onTextKey)
19495  StartFreqEntry.bind('<MouseWheel>', onTextScroll)
19496  StartFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19497  StartFreqEntry.bind("<Button-5>", onTextScroll)
19498  StartFreqEntry.bind('<Key>', onTextKey)
19499  StartFreqEntry.pack(side=LEFT)
19500  StartFreqEntry.delete(0,"end")
19501  StartFreqEntry.insert(0,10)
19502 
19503  Frange2 = Frame( frame2fr )
19504  Frange2.pack(side=TOP)
19505  stopfreqlab = Label(Frange2, text="Stopfreq")
19506  stopfreqlab.pack(side=LEFT)
19507  StopFreqEntry = Entry(Frange2, width=7, cursor='double_arrow')
19508  StopFreqEntry.bind('<Return>', onTextKey)
19509  StopFreqEntry.bind('<MouseWheel>', onStopfreqScroll)
19510  StopFreqEntry.bind("<Button-4>", onStopfreqScroll)# with Linux OS
19511  StopFreqEntry.bind("<Button-5>", onStopfreqScroll)
19512  StopFreqEntry.bind('<Key>', onTextKey)
19513  StopFreqEntry.pack(side=LEFT)
19514  StopFreqEntry.delete(0,"end")
19515  StopFreqEntry.insert(0,10000)
19516 
19517  HzScale = Frame( frame2fr )
19518  HzScale.pack(side=TOP)
19519  sarb1 = Radiobutton(HzScale, text="Lin F", variable=HScale, value=0, command=UpdateFreqTrace )
19520  sarb1.pack(side=LEFT)
19521  sarb2 = Radiobutton(HzScale, text="Log F", variable=HScale, value=1, command=UpdateFreqTrace )
19522  sarb2.pack(side=LEFT)
19523  #
19524  PhaseCenter = Frame( frame2fr )
19525  PhaseCenter.pack(side=TOP)
19526  PhCenlab = Label(PhaseCenter, text="Center Phase on")
19527  PhCenlab.pack(side=LEFT)
19528  PhCenFreqEntry = Entry(PhaseCenter, width=5, cursor='double_arrow')
19529  PhCenFreqEntry.bind('<Return>', onTextKey)
19530  PhCenFreqEntry.bind('<MouseWheel>', onTextScroll)
19531  PhCenFreqEntry.bind("<Button-4>", onTextScroll)# with Linux OS
19532  PhCenFreqEntry.bind("<Button-5>", onTextScroll)
19533  PhCenFreqEntry.bind('<Key>', onTextKey)
19534  PhCenFreqEntry.pack(side=LEFT)
19535  PhCenFreqEntry.delete(0,"end")
19536  PhCenFreqEntry.insert(0,RelPhaseCenter.get())
19537  #
19538  vertlabel = Label( frame2fr, text="Vertical Scale" )
19539  vertlabel.pack(side=TOP)
19540  savrb0 = Radiobutton(frame2fr, text="In dB", variable=SAVScale, value=0, command=UpdateFreqTrace )
19541  savrb0.pack(side=TOP)
19542  #
19543  DBrange = Frame( frame2fr )
19544  DBrange.pack(side=TOP)
19545  sab3 = Button(DBrange, text="+dB/div", style="W8.TButton", command=BDBdiv2)
19546  sab3.pack(side=LEFT)
19547  sab4 = Button(DBrange, text="-dB/div", style="W8.TButton", command=BDBdiv1)
19548  sab4.pack(side=LEFT)
19549 
19550  LVBrange = Frame( frame2fr )
19551  LVBrange.pack(side=TOP)
19552  sab5 = Button(LVBrange, text="LVL+10", style="W8.TButton", command=Blevel4)
19553  sab5.pack(side=LEFT)
19554  sab6 = Button(LVBrange, text="LVL-10", style="W8.TButton", command=Blevel3)
19555  sab6.pack(side=LEFT)
19556 
19557  LVSrange = Frame( frame2fr )
19558  LVSrange.pack(side=TOP)
19559  sab7 = Button(LVSrange, text="LVL+1", style="W8.TButton", command=Blevel2)
19560  sab7.pack(side=LEFT)
19561  sab8 = Button(LVSrange, text="LVL-1", style="W8.TButton", command=Blevel1)
19562  sab8.pack(side=LEFT)
19563  # Add RMS V controls
19564  vertscale = Frame( frame2fr )
19565  vertscale.pack(side=TOP)
19566  savlab1 = Label(vertscale, text="V RMS")
19567  savlab1.pack(side=LEFT)
19568  savrb1 = Radiobutton(vertscale, text="Lin", variable=SAVScale, value=1, command=UpdateFreqTrace )
19569  savrb1.pack(side=LEFT)
19570  savrb2 = Radiobutton(vertscale, text="Log", variable=SAVScale, value=2, command=UpdateFreqTrace )
19571  savrb2.pack(side=LEFT)
19572  sapsdcb = Checkbutton(frame2fr, text="PSD (sqrt Hz)", variable=SAVPSD)
19573  sapsdcb.pack(side=TOP)
19574  #
19575  vertmax = Frame( frame2fr )
19576  vertmax.pack(side=TOP)
19577  vertmaxlab = Label(vertmax, text="VRMS Max")
19578  vertmaxlab.pack(side=LEFT)
19579  SAvertmaxEntry = Spinbox(vertmax, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
19580  SAvertmaxEntry.bind('<MouseWheel>', onSpinBoxScroll)
19581  SAvertmaxEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19582  SAvertmaxEntry.bind("<Button-5>", onSpinBoxScroll)
19583  SAvertmaxEntry.delete(0,"end")
19584  SAvertmaxEntry.insert(0,"1.0")
19585  SAvertmaxEntry.pack(side=LEFT)
19586 
19596  vertmin = Frame( frame2fr )
19597  vertmin.pack(side=TOP)
19598  vertminlab = Label(vertmin, text="VRMS Min")
19599  vertminlab.pack(side=LEFT)
19600  SAvertminEntry = Spinbox(vertmin, width=6, cursor='double_arrow', values=SAMagdiv, command=BCHBIlevel)
19601  SAvertminEntry.bind('<MouseWheel>', onSpinBoxScroll)
19602  SAvertminEntry.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19603  SAvertminEntry.bind("<Button-5>", onSpinBoxScroll)
19604  SAvertminEntry.pack(side=LEFT)
19605  SAvertminEntry.delete(0,"end")
19606  SAvertminEntry.insert(0,"100uV")
19607 
19617  sadismiss1button = Button(frame2fr, text="Dismiss", style="W8.TButton", command=DestroySpectrumScreen)
19618  sadismiss1button.pack(side=TOP)
19619 
19620  ADI2 = Label(frame2fr, image=logo, anchor= "sw", compound="top") #, height=49, width=116
19621  ADI2.pack(side=TOP)
19622  if ShowBallonHelp > 0:
19623  sb_tip = CreateToolTip(sasb, 'Stop acquiring data')
19624  rb_tip = CreateToolTip(sarb, 'Start acquiring data')
19625  bless_tip = CreateToolTip(bless, 'Decrease FFT samples')
19626  bmore_tip = CreateToolTip(bmore, 'Increase FFT samples')
19627  b3_tip = CreateToolTip(sab3, 'Increase number of dB/Div')
19628  b4_tip = CreateToolTip(sab4, 'Decrease number of dB/Div')
19629  b5_tip = CreateToolTip(sab5, 'Increase Ref Level by 10 dB')
19630  b6_tip = CreateToolTip(sab6, 'Decrease Ref Level by 10 dB')
19631  b7_tip = CreateToolTip(sab7, 'Increase Ref Level by 1 dB')
19632  b8_tip = CreateToolTip(sab8, 'Decrease Ref Level by 1 dB')
19633  sadismiss1button_tip = CreateToolTip(sadismiss1button, 'Dismiss Spectrum Analyzer window')
19634  if LocalLanguage != "English":
19635  BLoadConfig(LocalLanguage) # load local language configuration
19636 
19638  global freqwindow, SpectrumScreenStatus, ca
19639 
19640  SpectrumScreenStatus.set(0)
19641  FreqDisp.set(0)
19642  FreqCheckBox()
19643  freqwindow.destroy()
19644  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
19645 #
19646 def XYcaresize(event):
19647  global XYca, GRWXY, XOLXY, GRHXY, Y0TXY, CANVASwidthXY, CANVASheightXY, FontSize
19648  global YminXY, YmaxXY, XminXY, XmaxXY
19649 
19650  XOLXY = FontSize * 7
19651  CANVASwidthXY = event.width - 4
19652  CANVASheightXY = event.height - 4
19653  GRWXY = CANVASwidthXY - (2*X0LXY) # 18 new grid width
19654  GRHXY = CANVASheightXY - int(10 * FontSize) # new grid height
19655  YminXY = Y0TXY # Minimum position of time grid (top)
19656  YmaxXY = Y0TXY + GRHXY # Maximum position of time grid (bottom)
19657  XminXY = X0LXY # Minimum position of time grid (left)
19658  XmaxXY = X0LXY + GRWXY # Maximum position of time grid (right)
19659  UpdateXYAll()
19660 #
19661 # ================ Make XY Plot sub window ==========================
19663  global logo, CANVASwidthXY, CANVASheightXY, Xsignal, EnableUserEntries
19664  global YsignalVA, YsignalVB, YsignalIA, YsignalIB, YsignalM, YsignalMX, YsignalMY
19665  global XYRefAV, XYRefAI, XYRefBV, XYRefBI, XYRefM, XYRefMX, XYRefMY
19666  global XYScreenStatus, MarkerXYScale, XYca, xywindow, RevDate, SWRev, XYDisp
19667  global CHAsbxy, CHBsbxy, CHAxylab, CHBxylab, CHAVPosEntryxy, CHBVPosEntryxy
19668  global CHAIsbxy, CHBIsbxy, CHAIPosEntryxy, CHBIPosEntryxy, ScreenXYrefresh
19669  global YminXY, Y0TXY, YmaxXY, GRHXY, XminXY, X0LXY, XmaxXY, X0LXY, GRWXY, CANVASwidthXY, CANVASheightXY
19670  global FrameRefief, BorderSize, LocalLanguage, User3Entry, User4Entry
19671  global math_tip, bsxy_tip, brxy_tip, snapbutton_tip, savebutton_tip, dismissxybutton_tip, CHAxylab_tip
19672  global CHBxylab_tip, CHAxyofflab_tip, CHBxyofflab_tip, CHAIxyofflab_tip, CHBIxyofflab_tip
19673 
19674  if XYScreenStatus.get() == 0:
19675  XYScreenStatus.set(1)
19676  XYDisp.set(1)
19677  XYCheckBox()
19678  YminXY = Y0TXY # Minimum position of XY grid (top)
19679  YmaxXY = Y0TXY + GRHXY # Maximum position of XY grid (bottom)
19680  XminXY = X0LXY # Minimum position of XY grid (left)
19681  XmaxXY = X0LXY + GRWXY # Maximum position of XY grid (right)
19682  CANVASwidthXY = GRWXY + (2*X0LXY) # The XY canvas width
19683  CANVASheightXY = GRHXY + 80 # The XY canvas height
19684  xywindow = Toplevel()
19685  xywindow.title("X-Y Plot " + SWRev + RevDate)
19686  xywindow.protocol("WM_DELETE_WINDOW", DestroyXYScreen)
19687  frame2xyr = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19688  frame2xyr.pack(side=RIGHT, expand=NO, fill=BOTH)
19689 
19690  frame2xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19691  frame2xy.pack(side=TOP, expand=YES, fill=BOTH)
19692 
19693  frame3xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19694  frame3xy.pack(side=TOP, expand=NO, fill=BOTH)
19695 
19696  frame4xy = Frame(xywindow, borderwidth=BorderSize, relief=FrameRefief)
19697  frame4xy.pack(side=TOP, expand=NO, fill=BOTH)
19698 
19699  XYca = Canvas(frame2xy, width=CANVASwidthXY, height=CANVASheightXY, background=COLORcanvas, cursor='cross')
19700  XYca.bind('<Configure>', XYcaresize)
19701  XYca.bind('<1>', onCanvasXYLeftClick)
19702  XYca.bind('<3>', onCanvasXYRightClick)
19703  XYca.bind("<Motion>",onCanvasMouse_xy)
19704  XYca.bind('<MouseWheel>', onCanvasXYScrollClick)
19705  XYca.bind("<Button-4>", onCanvasXYScrollClick)# with Linux OS
19706  XYca.bind("<Button-5>", onCanvasXYScrollClick)
19707  XYca.bind("<Up>", onCanvasUpArrow)
19708  XYca.bind("<Down>", onCanvasDownArrow)
19709  XYca.bind("<Left>", onCanvasLeftArrow)
19710  XYca.bind("<Right>", onCanvasRightArrow)
19711  XYca.bind("<space>", onCanvasSpaceBar)
19712  XYca.bind("a", onCanvasAverage)
19713  XYca.pack(side=TOP, fill=BOTH, expand=YES)
19714  #
19715  RUNframe = Frame( frame2xyr )
19716  RUNframe.pack(side=TOP)
19717  rbxy = Button(RUNframe, text="Run", style="Run.TButton", command=BStart)
19718  rbxy.pack(side=LEFT)
19719  sbxy = Button(RUNframe, text="Stop", style="Stop.TButton", command=BStop)
19720  sbxy.pack(side=LEFT)
19721  # Open Math trace menu
19722  mathbt = Button(frame2xyr, text="Math", style="W5.TButton", command = NewEnterMathControls)
19723  mathbt.pack(side=TOP) #, anchor=W)
19724  # Disply mode menu
19725  # X - Y mode signal select
19726  AxisLabX = Label(frame2xyr, text ="-X Axis-", style="A10R1.TLabelframe.Label")
19727  AxisLabX.pack(side=TOP)
19728  chaxmenu = Frame( frame2xyr )
19729  chaxmenu.pack(side=TOP)
19730  rbx2 = Radiobutton(chaxmenu, text='CA-V', variable=Xsignal, value=1, command=UpdateXYTrace)
19731  rbx2.pack(side=LEFT, anchor=W)
19732  rbx3 = Radiobutton(chaxmenu, text='CA-I', variable=Xsignal, value=2, command=UpdateXYTrace)
19733  rbx3.pack(side=LEFT, anchor=W)
19734  chbxmenu = Frame( frame2xyr )
19735  chbxmenu.pack(side=TOP)
19736  rbx4 = Radiobutton(chbxmenu, text='CB-V', variable=Xsignal, value=3, command=UpdateXYTrace)
19737  rbx4.pack(side=LEFT, anchor=W)
19738  rbx5 = Radiobutton(chbxmenu, text='CB-I', variable=Xsignal, value=4, command=UpdateXYTrace)
19739  rbx5.pack(side=LEFT, anchor=W)
19740  rbx7 = Radiobutton(frame2xyr, text='Histogram CA-V', variable=Xsignal, value=6, command=BHistAsPercent)
19741  rbx7.pack(side=TOP)
19742  rbx8 = Radiobutton(frame2xyr, text='Histogram CB-V', variable=Xsignal, value=7, command=BHistAsPercent)
19743  rbx8.pack(side=TOP)
19744  rbx6 = Radiobutton(frame2xyr, text='Math', variable=Xsignal, value=5, command=UpdateXYTrace)
19745  rbx6.pack(side=TOP)
19746  #
19747  AxisLabY = Label(frame2xyr, text ="-Y Axis-", style="A10R2.TLabelframe.Label")
19748  AxisLabY.pack(side=TOP)
19749  chaymenu = Frame( frame2xyr )
19750  chaymenu.pack(side=TOP)
19751  rby2 = Checkbutton(chaymenu, text='CA-V', variable=YsignalVA, command=UpdateXYTrace)
19752  rby2.pack(side=LEFT, anchor=W)
19753  rby3 = Checkbutton(chaymenu, text='CA-I', variable=YsignalIA, command=UpdateXYTrace)
19754  rby3.pack(side=LEFT, anchor=W)
19755  chbymenu = Frame( frame2xyr )
19756  chbymenu.pack(side=TOP)
19757  rby4 = Checkbutton(chbymenu, text='CB-V', variable=YsignalVB, command=UpdateXYTrace)
19758  rby4.pack(side=LEFT, anchor=W)
19759  rby5 = Checkbutton(chbymenu, text='CB-I', variable=YsignalIB, command=UpdateXYTrace)
19760  rby5.pack(side=LEFT, anchor=W)
19761  rby7 = Checkbutton(frame2xyr, text='Math', variable=YsignalM, command=UpdateXYTrace)
19762  rby7.pack(side=TOP)
19763  mymenu = Frame( frame2xyr )
19764  mymenu.pack(side=TOP)
19765  rby7 = Checkbutton(mymenu, text='Math-X', variable=YsignalMX, command=UpdateXYTrace)
19766  rby7.pack(side=LEFT, anchor=W)
19767  rby8 = Checkbutton(mymenu, text='Math-Y', variable=YsignalMY, command=UpdateXYTrace)
19768  rby8.pack(side=LEFT, anchor=W)
19769  # show cursor menu buttons
19770  cursormenu = Frame( frame2xyr )
19771  cursormenu.pack(side=TOP)
19772  cb1 = Checkbutton(cursormenu, text='X-Cur', variable=ShowXCur)
19773  cb1.pack(side=LEFT, anchor=W)
19774  cb2 = Checkbutton(cursormenu, text='Y-Cur', variable=ShowYCur)
19775  cb2.pack(side=LEFT, anchor=W)
19776  cb4 = Checkbutton(frame2xyr, text='Persistance', variable=ScreenXYrefresh, command=UpdateXYTrace)
19777  cb4.pack(side=TOP)
19778  #
19779  # Reference trace menu
19780  XYrefmenu = Menubutton(frame2xyr, text="Ref Traces", style="W11.TButton")
19781  XYrefmenu.menu = Menu(XYrefmenu, tearoff = 0 )
19782  XYrefmenu["menu"] = XYrefmenu.menu
19783  XYrefmenu.menu.add_command(label="Save SnapShot", command=BSnapShotXY)
19784  XYrefmenu.menu.add_checkbutton(label="CA-V", variable=XYRefAV, command=UpdateXYTrace)
19785  XYrefmenu.menu.add_checkbutton(label="CA-I", variable=XYRefAI, command=UpdateXYTrace)
19786  XYrefmenu.menu.add_checkbutton(label="CB-V", variable=XYRefBV, command=UpdateXYTrace)
19787  XYrefmenu.menu.add_checkbutton(label="CB-I", variable=XYRefBI, command=UpdateXYTrace)
19788  XYrefmenu.menu.add_checkbutton(label="Math", variable=XYRefM, command=UpdateXYTrace)
19789  XYrefmenu.menu.add_checkbutton(label="Math-X", variable=XYRefMX, command=UpdateXYTrace)
19790  XYrefmenu.menu.add_checkbutton(label="Math-Y", variable=XYRefMY, command=UpdateXYTrace)
19791  XYrefmenu.pack(side=TOP) # , anchor=W)
19792 
19794  dismissxybutton = Button(frame2xyr, style="W7.TButton", text="Dismiss", command=DestroyXYScreen)
19795  dismissxybutton.pack(side=TOP)
19796  # Add a pair of user entry wigets
19797  if EnableUserEntries > 0:
19798  UserEnt = Frame( frame2xyr )
19799  UserEnt.pack(side=TOP)
19800  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
19801  userentlab.pack(side=LEFT,fill=X)
19802  User3Entry = Entry(UserEnt, width=5, cursor='double_arrow')
19803  User3Entry.bind('<Return>', onTextKey)
19804  User3Entry.bind('<MouseWheel>', onTextScroll)
19805  User3Entry.bind("<Button-4>", onTextScroll)# with Linux OS
19806  User3Entry.bind("<Button-5>", onTextScroll)
19807  User3Entry.bind('<Key>', onTextKey)
19808  User3Entry.pack(side=LEFT)
19809  User3Entry.delete(0,"end")
19810  User3Entry.insert(0,0.0)
19811  User4Entry = Entry(UserEnt, width=5, cursor='double_arrow')
19812  User4Entry.bind('<Return>', onTextKey)
19813  User4Entry.bind('<MouseWheel>', onTextScroll)
19814  User4Entry.bind("<Button-4>", onTextScroll)# with Linux OS
19815  User4Entry.bind("<Button-5>", onTextScroll)
19816  User4Entry.bind('<Key>', onTextKey)
19817  User4Entry.pack(side=LEFT)
19818  User4Entry.delete(0,"end")
19819  User4Entry.insert(0,0.0)
19820  #
19821  ADI1xy = Label(frame2xyr, image=logo, anchor= "sw", compound="top") # , height=49, width=116
19822  ADI1xy.pack(side=TOP)
19823  # Bottom Buttons
19824  MarkerXYScale = IntVar(0)
19825  MarkerXYScale.set(1)
19826  # Voltage channel A
19827  CHAsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHvpdiv)
19828  CHAsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19829  CHAsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19830  CHAsbxy.bind("<Button-5>", onSpinBoxScroll)
19831  CHAsbxy.pack(side=LEFT)
19832  CHAsbxy.delete(0,"end")
19833  CHAsbxy.insert(0,0.5)
19834  CHAxylab = Button(frame3xy, text="CA V/Div", style="Rtrace1.TButton", command=SetXYScaleA)
19835  CHAxylab.pack(side=LEFT)
19836 
19837  CHAVPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
19838  CHAVPosEntryxy.bind('<Return>', onTextKey)
19839  CHAVPosEntryxy.bind('<MouseWheel>', onTextScroll)
19840  CHAVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19841  CHAVPosEntryxy.bind("<Button-5>", onTextScroll)
19842  CHAVPosEntryxy.bind('<Key>', onTextKey)
19843  CHAVPosEntryxy.pack(side=LEFT)
19844  CHAVPosEntryxy.delete(0,"end")
19845  CHAVPosEntryxy.insert(0,2.5)
19846  CHAofflabxy = Button(frame3xy, text="CA V Pos", style="Rtrace1.TButton", command=SetXYVAPoss)
19847  CHAofflabxy.pack(side=LEFT)
19848  # Current channel A
19849  CHAIsbxy = Spinbox(frame3xy, width=4, cursor='double_arrow', values=CHipdiv)
19850  CHAIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19851  CHAIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19852  CHAIsbxy.bind("<Button-5>", onSpinBoxScroll)
19853  CHAIsbxy.pack(side=LEFT)
19854  CHAIsbxy.delete(0,"end")
19855  CHAIsbxy.insert(0,50.0)
19856  CHAIlabxy = Label(frame3xy, text="CA mA/Div", style="Strace3.TButton")
19857  CHAIlabxy.pack(side=LEFT)
19858 
19859  CHAIPosEntryxy = Entry(frame3xy, width=5, cursor='double_arrow')
19860  CHAIPosEntryxy.bind('<Return>', onTextKey)
19861  CHAIPosEntryxy.bind('<MouseWheel>', onTextScroll)
19862  CHAIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19863  CHAIPosEntryxy.bind("<Button-5>", onTextScroll)
19864  CHAIPosEntryxy.bind('<Key>', onTextKey)
19865  CHAIPosEntryxy.pack(side=LEFT)
19866  CHAIPosEntryxy.delete(0,"end")
19867  CHAIPosEntryxy.insert(0,0.0)
19868  CHAIofflabxy = Button(frame3xy, text="CA I Pos", style="Rtrace3.TButton", command=SetXYIAPoss)
19869  CHAIofflabxy.pack(side=LEFT)
19870  # Voltage channel B
19871  CHBsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHvpdiv)
19872  CHBsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19873  CHBsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19874  CHBsbxy.bind("<Button-5>", onSpinBoxScroll)
19875  CHBsbxy.pack(side=LEFT)
19876  CHBsbxy.delete(0,"end")
19877  CHBsbxy.insert(0,0.5)
19878  #
19879  CHBxylab = Button(frame4xy, text="CB V/Div", style="Strace2.TButton", command=SetXYScaleB)
19880  CHBxylab.pack(side=LEFT)
19881 
19882  CHBVPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
19883  CHBVPosEntryxy.bind('<Return>', onTextKey)
19884  CHBVPosEntryxy.bind('<MouseWheel>', onTextScroll)
19885  CHBVPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19886  CHBVPosEntryxy.bind("<Button-5>", onTextScroll)
19887  CHBVPosEntryxy.bind('<Key>', onTextKey)
19888  CHBVPosEntryxy.pack(side=LEFT)
19889  CHBVPosEntryxy.delete(0,"end")
19890  CHBVPosEntryxy.insert(0,2.5)
19891  CHBofflabxy = Button(frame4xy, text="CB V Pos", style="Rtrace2.TButton", command=SetXYVBPoss)
19892  CHBofflabxy.pack(side=LEFT)
19893  # Current channel B
19894  CHBIsbxy = Spinbox(frame4xy, width=4, cursor='double_arrow', values=CHipdiv) #
19895  CHBIsbxy.bind('<MouseWheel>', onSpinBoxScroll)
19896  CHBIsbxy.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
19897  CHBIsbxy.bind("<Button-5>", onSpinBoxScroll)
19898  CHBIsbxy.pack(side=LEFT)
19899  CHBIsbxy.delete(0,"end")
19900  CHBIsbxy.insert(0,50.0)
19901  CHBIlabxy = Label(frame4xy, text="CB mA/Div", style="Strace4.TButton")
19902  CHBIlabxy.pack(side=LEFT)
19903 
19904  CHBIPosEntryxy = Entry(frame4xy, width=5, cursor='double_arrow')
19905  CHBIPosEntryxy.bind('<Return>', onTextKey)
19906  CHBIPosEntryxy.bind('<MouseWheel>', onTextScroll)
19907  CHBIPosEntryxy.bind("<Button-4>", onTextScroll)# with Linux OS
19908  CHBIPosEntryxy.bind("<Button-5>", onTextScroll)
19909  CHBIPosEntryxy.bind('<Key>', onTextKey)
19910  CHBIPosEntryxy.pack(side=LEFT)
19911  CHBIPosEntryxy.delete(0,"end")
19912  CHBIPosEntryxy.insert(0,0.0)
19913  CHBIofflabxy = Button(frame4xy, text="CB I Pos", style="Rtrace4.TButton", command=SetXYIBPoss)
19914  CHBIofflabxy.pack(side=LEFT)
19915  #
19916  if ShowBallonHelp > 0:
19917  #xb1_tip = CreateToolTip(xb1, 'Enter formula for X axis Math trace')
19918  #xb2_tip = CreateToolTip(xb2, 'Enter which axis controls to use for X axis Math trace')
19919  #yb1_tip = CreateToolTip(yb1, 'Enter formula for Y axis Math trace')
19920  #yb2_tip = CreateToolTip(yb2, 'Enter which axis controls to use for Y axis Math trace')
19921  math_tip = CreateToolTip(mathbt, 'Open Math window')
19922  bsxy_tip = CreateToolTip(sbxy, 'Stop acquiring data')
19923  brxy_tip = CreateToolTip(rbxy, 'Start acquiring data')
19924  snapbutton_tip = CreateToolTip(snapbutton, 'Take snap shot of current trace')
19925  savebutton_tip = CreateToolTip(savebutton, 'Save current trace to EPS file')
19926  dismissxybutton_tip = CreateToolTip(dismissxybutton, 'Diamiss X-Y plot window')
19927  CHAxylab_tip = CreateToolTip(CHAxylab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
19928  CHBxylab_tip = CreateToolTip(CHBxylab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
19929  CHAxyofflab_tip = CreateToolTip(CHAofflabxy, 'Set CHA-V position to DC average of signal')
19930  CHBxyofflab_tip = CreateToolTip(CHBofflabxy, 'Set CHB-V position to DC average of signal')
19931  CHAIxyofflab_tip = CreateToolTip(CHAIofflabxy, 'Set CHA-I position to DC average of signal')
19932  CHBIxyofflab_tip = CreateToolTip(CHBIofflabxy, 'Set CHB-I position to DC average of signal')
19933  if LocalLanguage != "English":
19934  BLoadConfig(LocalLanguage)
19935 
19937  global xywindow, XYScreenStatus, ca, XYDisp
19938 
19939  XYScreenStatus.set(0)
19940  XYDisp.set(0)
19941  XYCheckBox()
19942  xywindow.destroy()
19943  ca.bind_all('<MouseWheel>', onCanvasClickScroll)
19944 #
19945 # Optional Calibration procedure routine
19946 #
19948  global DevID, devx, CHA, CHB, RevDate, OnBoardRes, AD584act, FWRevOne
19949  global discontloop, contloop, session, AWGSync, SWRev
19950  # global OnBoardResAgnd, OnBoardResA25, OnBoardResBgnd, OnBoardResB25
19951  # setup cal results window
19952  if FWRevOne < 2.06: # Check firmware revision level > 2.06
19953  showwarning("WARNING","Out of date Firmware Revision!")
19954  return
19955  calwindow = Toplevel()
19956  calwindow.title("ALM1000 Calibration tool " + SWRev + RevDate)
19957  # display wigets
19958  SCallab = Label(calwindow, text="Channel Gain / Offset calibration")
19959  SCallab.grid(row=0, column=0, columnspan=2, sticky=W)
19960  labelA0 = Label(calwindow, style="A12B.TLabel")
19961  labelA0.grid(row=1, column=0, columnspan=2, sticky=W)
19962  labelA0.config(text = "CA gnd Volts")
19963  labelAMax = Label(calwindow, style="A12B.TLabel")
19964  labelAMax.grid(row=2, column=0, columnspan=2, sticky=W)
19965  labelAMax.config(text = "CA 584 Volts")
19966  labelAMin = Label(calwindow, style="A12B.TLabel")
19967  labelAMin.grid(row=3, column=0, columnspan=2, sticky=W)
19968  labelAMin.config(text = "CA 5V Src I ")
19969  labelB0 = Label(calwindow, style="A12B.TLabel")
19970  labelB0.grid(row=4, column=0, columnspan=2, sticky=W)
19971  labelB0.config(text = "CA gnd Volts")
19972  labelBMax = Label(calwindow, style="A12B.TLabel")
19973  labelBMax.grid(row=5, column=0, columnspan=2, sticky=W)
19974  labelBMax.config(text = "CB 584 Volts")
19975  labelBMin = Label(calwindow, style="A12B.TLabel")
19976  labelBMin.grid(row=6, column=0, columnspan=2, sticky=W)
19977  labelBMin.config(text = "CB 5V Src I ")
19978  labelAB = Label(calwindow, style="A12B.TLabel")
19979  labelAB.grid(row=7, column=0, columnspan=2, sticky=W)
19980  labelAB.config(text = "CA 0V Src I")
19981  labelBA = Label(calwindow, style="A12B.TLabel")
19982  labelBA.grid(row=8, column=0, columnspan=2, sticky=W)
19983  labelBA.config(text = "CA 0V Src I")
19984  labelSIA0 = Label(calwindow, style="A12B.TLabel")
19985  labelSIA0.grid(row=9, column=0, columnspan=2, sticky=W)
19986  labelSIA0.config(text = "CA 2.5 Src 0 I")
19987  labelSIA = Label(calwindow, style="A12B.TLabel")
19988  labelSIA.grid(row=10, column=0, columnspan=2, sticky=W)
19989  labelSIA.config(text = "CA 50 Src 100 ")
19990  labelSIAN = Label(calwindow, style="A12B.TLabel")
19991  labelSIAN.grid(row=11, column=0, columnspan=2, sticky=W)
19992  labelSIAN.config(text = "CA 50 Src -45")
19993  labelSIB0 = Label(calwindow, style="A12B.TLabel")
19994  labelSIB0.grid(row=12, column=0, columnspan=2, sticky=W)
19995  labelSIB0.config(text = "CB 2.5 Src 0 I")
19996  labelSIB = Label(calwindow, style="A12B.TLabel")
19997  labelSIB.grid(row=13, column=0, columnspan=2, sticky=W)
19998  labelSIB.config(text = "CB 50 Src 100 ")
19999  labelSIBN = Label(calwindow, style="A12B.TLabel")
20000  labelSIBN.grid(row=14, column=0, columnspan=2, sticky=W)
20001  labelSIBN.config(text = "CB 50 Src -45")
20002  # set to default mux and dac settings
20003  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
20004  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set to addr DAC B
20005  AWGSync.set(1)
20006  BAWGSync()
20007  if session.continuous:
20008  print( "ending session")
20009  session.end()
20010  # Setup ADALM1000
20011  if askyesno("Reset Calibration", "Do You Need To Reset Default Calibration?", parent=calwindow):
20012  #print(devx.calibration)
20013  try:
20014  devx.write_calibration("calib_default.txt")
20015  #print "wrote calib_default.txt"
20016  except:
20017  filename = askopenfilename(defaultextension = ".txt", filetypes=[("Default Cal File", "*.txt")], parent=calwindow)
20018  devx.write_calibration(filename)
20019  #print(devx.calibration)
20020  #
20021  devidstr = DevID[17:31]
20022  filename = "calib" + devidstr + ".txt"
20023  if os.path.isfile(filename):
20024  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?", parent=calwindow):
20025  devx.write_calibration(filename)
20026  #print "wrote old ", filename
20027  calwindow.destroy()
20028  return
20029  else:
20030  if askyesno("Continue?", "Continure with self calibration?", parent=calwindow):
20031  donothing()
20032  else:
20033  calwindow.destroy()
20034  return
20035  #
20036  CalFile = open(filename, "w")
20037  #
20038  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20039  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20040  devx.ctrl_transfer( 0x40, 0x50, 34, 0, 0, 0, 100) # close voltage sense loop just in case
20041  devx.ctrl_transfer( 0x40, 0x50, 39, 0, 0, 0, 100) # close voltage sense loop just in case
20042  ADsignal1 = [] # Ain signal array channel
20043  ADsignal1 = devx.get_samples(1010)
20044  # Pause whie user connects external voltage reference AD584
20045  BadData = 1
20046  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20047  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20048  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20049  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20050  RequestVRef = askstring("External Reference", "Enter External Reference Voltage", initialvalue=AD584act, parent=root)
20051  try:
20052  AD584act = float(RequestVRef)*1.0
20053  except:
20054  AD584act = 3.3
20055  showinfo("CONNECT","Connect External Voltage to both CHA and CHB inputs.", parent=calwindow)
20056  while (BadData): # loop till good reading
20057  # Get A and B AD584 data
20058  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20059  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20060  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20061  CHA584Raw = CHB584Raw = 0.0 # initalize measurment variable
20062  # get_samples returns a list of values for voltage [0] and current [1]
20063  for index in range(1000): # calculate average
20064  CHA584Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20065  CHB584Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20066 
20067  CHA584Raw = CHA584Raw / 1000.0 # calculate average
20068  CHB584Raw = CHB584Raw / 1000.0 # calculate average
20069  VString = "Extern A Volts " + ' {0:.4f} '.format(CHA584Raw) # format with 4 decimal places
20070  labelAMax.config(text = VString) # change displayed value
20071  VString = "Extern B Volts " + ' {0:.4f} '.format(CHB584Raw) # format with 4 decimal places
20072  labelBMax.config(text = VString) # change displayed value
20073  Lower = AD584act - 0.3
20074  Upper = AD584act + 0.3
20075  if CHA584Raw < Lower or CHA584Raw > Upper or CHB584Raw < Lower or CHB584Raw > Upper:
20076  if askyesno("CONNECT","Did not get good data from Ref V check connections!\n Abort(Y) or Try again(N)", parent=calwindow):
20077  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20078  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20079  contloop = 0
20080  discontloop = 1
20081  calwindow.destroy()
20082  return
20083  else:
20084  BadData = 0
20085  #
20086  showinfo("DISCONNECT","Disconnect everything from CHA and CHB pins.", parent=calwindow)
20087  CHAGndRaw = CHBGndRaw = CHAI0gRaw = CHBI0gRaw = 0.0 # initalize measurment variable
20088  # Get A GND and B GND data
20089  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20090  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set GND switch to closed
20091  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20092  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
20093  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20094  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20095  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20096  # get_samples returns a list of values for voltage [0] and current [1]
20097  for index in range(1000): # calculate average
20098  CHAGndRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20099  CHBGndRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20100  CHAI0gRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20101  CHBI0gRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20102 
20103  CHAGndRaw = CHAGndRaw / 1000.0 # calculate average
20104  CHAI0gRaw = CHAI0gRaw / 1000.0
20105  CHBGndRaw = CHBGndRaw / 1000.0 # calculate average
20106  CHBI0gRaw = CHBI0gRaw / 1000.0
20107  VString = "CA gnd Volts " + ' {0:.4f} '.format(CHAGndRaw) # format with 4 decimal places
20108  labelA0.config(text = VString) # change displayed value
20109  VString = "CB gnd Volts " + ' {0:.4f} '.format(CHBGndRaw) # format with 4 decimal places
20110  labelB0.config(text = VString) # change displayed value
20111  CHA2p5Raw = CHB2p5Raw = CHAI02p5Raw = CHBI02p5Raw = 0.0 # initalize measurment variable
20112  # Get A and B data for internal 2.5 rail
20113  CHA.mode = Mode.HI_Z # Put CHA in Hi Z mode
20114  CHB.mode = Mode.HI_Z # Put CHB in Hi Z mode
20115  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set 2.5 V switch to closed
20116  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20117  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20118  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20119  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20120  # get_samples returns a list of values for voltage [0] and current [1]
20121  for index in range(1000): # calculate average
20122  CHA2p5Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20123  CHB2p5Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20124  CHAI02p5Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20125  CHBI02p5Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20126 
20127  CHA2p5Raw = CHA2p5Raw / 1000.0 # calculate average
20128  CHAI02p5Raw = CHAI02p5Raw / 1000.0
20129  CHB2p5Raw = CHB2p5Raw / 1000.0 # calculate average
20130  CHBI02p5Raw = CHBI02p5Raw / 1000.0
20131  # Get A force 0V and B force 0V data
20132  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20133  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20134  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20135  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20136  CHA.mode = Mode.SVMI
20137  CHA.constant(0.0)
20138  CHB.mode = Mode.SVMI
20139  CHB.constant(0.0)
20140  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20141  CHAF0vRaw = CHBF0vRaw = CHAI0F0Raw = CHBI0F0Raw = 0.0 # initalize measurment variable
20142  # get_samples returns a list of values for voltage [0] and current [1]
20143  for index in range(1000): # calculate average
20144  CHAF0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20145  CHBF0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20146  CHAI0F0Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20147  CHBI0F0Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20148 
20149  CHAF0vRaw = CHAF0vRaw / 1000.0 # calculate average
20150  CHAI0F0Raw = CHAI0F0Raw / 1000.0
20151  CHBF0vRaw = CHBF0vRaw / 1000.0 # calculate average
20152  CHBI0F0Raw = CHBI0F0Raw / 1000.0
20153  # Get A force 2.5V and B force 2.5V data
20154  CHA.mode = Mode.SVMI
20155  CHA.constant(4.5)
20156  CHB.mode = Mode.SVMI
20157  CHB.constant(4.5)
20158  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20159  CHAF25vRaw = CHAI0F25Raw = CHBF25vRaw = CHBI0F25Raw = 0.0 # initalize measurment variable
20160  # get_samples returns a list of values for voltage [0] and current [1]
20161  for index in range(1000): # calculate average
20162  CHAF25vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20163  CHBF25vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20164  CHAI0F25Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20165  CHBI0F25Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20166 
20167  CHAF25vRaw = CHAF25vRaw / 1000.0 # calculate average
20168  CHAI0F25Raw = CHAI0F25Raw / 1000.0
20169  CHBF25vRaw = CHBF25vRaw / 1000.0 # calculate average
20170  CHBI0F25Raw = CHBI0F25Raw / 1000.0
20171  #
20172  # Get A and B measure current data for int 50 res to gnd at 5V
20173  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to open
20174  devx.ctrl_transfer(0x40, 0x50, 33, 0, 0, 0, 100) # set CHA GND switch to closed
20175  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20176  devx.ctrl_transfer(0x40, 0x50, 38, 0, 0, 0, 100) # set CHB GND switch to closed
20177  CHA.mode = Mode.SVMI
20178  CHA.constant(5.0)
20179  CHB.mode = Mode.SVMI
20180  CHB.constant(5.0)
20181  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20182  CHASr5vRaw = CHAISr5vRaw = CHBSr5vRaw = CHBISr5vRaw = 0.0 # initalize measurment variable
20183  for index in range(1000): # calculate average
20184  CHASr5vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20185  CHBSr5vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20186  CHAISr5vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20187  CHBISr5vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20188 
20189  CHASr5vRaw = CHASr5vRaw / 1000.0 # calculate average
20190  CHAISr5vRaw = CHAISr5vRaw / 1000.0
20191  CHBSr5vRaw = CHBSr5vRaw / 1000.0 # calculate average
20192  CHBISr5vRaw = CHBISr5vRaw / 1000.0
20193  VString = "CA 5V Src I " + ' {0:.4f} '.format(CHAISr5vRaw) # format with 4 decimal places
20194  labelAMin.config(text = VString) # change displayed value
20195  VString = "CB 5V Src I " + ' {0:.4f} '.format(CHBISr5vRaw) # format with 4 decimal places
20196  labelBMin.config(text = VString) # change displayed value
20197  # Get A and B measure current data for int 50 res to 2.5 V at 0V
20198  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20199  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20200  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20201  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20202  CHA.mode = Mode.SVMI
20203  CHA.constant(0.001)
20204  CHB.mode = Mode.SVMI
20205  CHB.constant(0.001)
20206  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20207  CHASr0vRaw = CHAISr0vRaw = CHBSr0vRaw = CHBISr0vRaw = 0.0 # initalize measurment variable
20208  for index in range(1000): # calculate average
20209  CHASr0vRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20210  CHBSr0vRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20211  CHAISr0vRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20212  CHBISr0vRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20213 
20214  CHASr0vRaw = CHASr0vRaw / 1000.0 # calculate average
20215  CHAISr0vRaw = CHAISr0vRaw / 1000.0
20216  CHBSr0vRaw = CHBSr0vRaw / 1000.0 # calculate average
20217  CHBISr0vRaw = CHBISr0vRaw / 1000.0
20218  VString = "CA 0V Src I " + ' {0:.4f} '.format(CHAISr0vRaw) # format with 4 decimal places
20219  labelAB.config(text = VString) # change displayed value
20220  VString = "CB 0V Src I " + ' {0:.4f} '.format(CHBISr0vRaw) # format with 4 decimal places
20221  labelBA.config(text = VString) # change displayed value
20222 
20223  # Get A and B force 0.0 current data for int 50 res to 2.5 rail
20224  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20225  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20226  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20227  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20228  CHA.mode = Mode.SIMV
20229  CHA.constant(0.0)
20230  CHB.mode = Mode.SIMV
20231  CHB.constant(0.0)
20232  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20233  CHAVSr0iRaw = CHAISr0iRaw = CHBVSr0iRaw = CHBISr0iRaw = 0.0 # initalize measurment variable
20234  for index in range(1000): # calculate average
20235  CHAVSr0iRaw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20236  CHBVSr0iRaw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20237  CHAISr0iRaw += ADsignal1[index+10][0][1] # Sum for average CA current
20238  CHBISr0iRaw += ADsignal1[index+10][1][1] # Sum for average CB current
20239 
20240  CHAVSr0iRaw = CHAVSr0iRaw / 1000.0 # calculate average
20241  CHAISr0iRaw = CHAISr0iRaw / 1000.0
20242  CHBVSr0iRaw = CHBVSr0iRaw / 1000.0 # calculate average
20243  CHBISr0iRaw = CHBISr0iRaw / 1000.0
20244  VString = "CA 2.5 Src 0 I" + ' {0:.4f} '.format(CHAISr0iRaw) # format with 4 decimal places
20245  labelSIA0.config(text = VString) # change displayed value
20246  VString = "CB 2.5 Src 0 I" + ' {0:.4f} '.format(CHBISr0iRaw) # format with 4 decimal places
20247  labelSIB0.config(text = VString) # change displayed value
20248  #
20249  # Get A and B force +0.45 current data for int 50 res to 2.5 V rail
20250  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20251  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20252  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20253  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20254  CHA.mode = Mode.SIMV
20255  CHA.constant(0.045)
20256  CHB.mode = Mode.SIMV
20257  CHB.constant(0.045)
20258  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20259  CHAVSr100Raw = CHAISr100Raw = CHBVSr100Raw = CHBISr100Raw = 0.0 # initalize measurment variable
20260  for index in range(1000): # calculate average
20261  CHAVSr100Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20262  CHBVSr100Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20263  CHAISr100Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20264  CHBISr100Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20265 
20266  CHAVSr100Raw = CHAVSr100Raw / 1000.0 # calculate average
20267  CHAISr100Raw = CHAISr100Raw / 1000.0
20268  CHBVSr100Raw = CHBVSr100Raw / 1000.0 # calculate average
20269  CHBISr100Raw = CHBISr100Raw / 1000.0
20270  VString = "CA 50 Src +45 " + ' {0:.4f} '.format(CHAVSr100Raw) # format with 4 decimal places
20271  labelSIA.config(text = VString) # change displayed value
20272  VString = "CB 50 Src +45 " + ' {0:.4f} '.format(CHBVSr100Raw) # format with 4 decimal places
20273  labelSIB.config(text = VString) # change displayed value
20274  #
20275  # Get A and B force -0.045 current data for int 50 res to 2.5 V rail
20276  devx.ctrl_transfer(0x40, 0x50, 32, 0, 0, 0, 100) # set CHA 2.5 V switch to closed
20277  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set CHA GND switch to open
20278  devx.ctrl_transfer(0x40, 0x50, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to closed
20279  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20280  CHA.mode = Mode.SIMV
20281  CHA.constant(-0.045)
20282  CHB.mode = Mode.SIMV
20283  CHB.constant(-0.045)
20284  ADsignal1 = devx.get_samples(1010) # get samples for dev channel A0 and B0
20285  CHAVSrN45Raw = CHAISrN45Raw = CHBVSrN45Raw = CHBISrN45Raw = 0.0 # initalize measurment variable
20286  for index in range(1000): # calculate average
20287  CHAVSrN45Raw += ADsignal1[index+10][0][0] # Sum for average CA voltage
20288  CHBVSrN45Raw += ADsignal1[index+10][1][0] # Sum for average CB voltage
20289  CHAISrN45Raw += ADsignal1[index+10][0][1] # Sum for average CA current
20290  CHBISrN45Raw += ADsignal1[index+10][1][1] # Sum for average CB current
20291 
20292  CHAVSrN45Raw = CHAVSrN45Raw / 1000.0 # calculate average
20293  CHAISrN45Raw = CHAISrN45Raw / 1000.0
20294  CHBVSrN45Raw = CHBVSrN45Raw / 1000.0 # calculate average
20295  CHBISrN45Raw = CHBISrN45Raw / 1000.0
20296  VString = "CA 50 Src -45 " + ' {0:.4f} '.format(CHAVSrN45Raw) # format with 4 decimal places
20297  labelSIAN.config(text = VString) # change displayed value
20298  VString = "CB 50 Src -45 " + ' {0:.4f} '.format(CHBVSrN45Raw) # format with 4 decimal places
20299  labelSIBN.config(text = VString) # change displayed value
20300  # return all switches to open
20301  devx.ctrl_transfer(0x40, 0x51, 32, 0, 0, 0, 100) # set 2.5 V switch to open
20302  devx.ctrl_transfer(0x40, 0x51, 33, 0, 0, 0, 100) # set GND switch to open
20303  devx.ctrl_transfer(0x40, 0x51, 37, 0, 0, 0, 100) # set CHB 2.5 V switch to open
20304  devx.ctrl_transfer(0x40, 0x51, 38, 0, 0, 0, 100) # set CHB GND switch to open
20305  # Caculate voltage gain errors
20306  #
20307  CHAF25V = CHAF25vRaw * ( AD584act / CHA584Raw )
20308  CHBF25V = CHBF25vRaw * ( AD584act / CHB584Raw )
20309  #
20310  CHASr5v = CHASr5vRaw * ( AD584act / CHA584Raw ) # calculate actual voltage
20311  CHBSr5v = CHBSr5vRaw * ( AD584act / CHB584Raw ) # calculate actual voltage
20312  #
20313  CHA2p5 = CHA2p5Raw * ( AD584act / CHA584Raw )
20314  # print "calculated fixed 2.5 from CHA ", CHA2p5
20315  CHB2p5 = CHB2p5Raw * ( AD584act / CHB584Raw )
20316  # print "calculated fixed 2.5 from CHB ", CHB2p5
20317  #
20318  CHAActSrI = CHASr5v / OnBoardRes # adjust resistor value to include switch ron
20319  CHBActSrI = CHBSr5v / OnBoardRes # adjust resistor value to include switch ron
20320  #
20321  CHAActSnkI = CHASr0vRaw - CHA2p5 / OnBoardRes # adjust resistor value to include switch ron
20322  CHBActSnkI = CHBSr0vRaw - CHB2p5 / OnBoardRes # adjust resistor value to include switch ron
20323  #
20324  CHASr0i = CHAVSr0iRaw * ( AD584act / CHA584Raw )
20325  CHASr0iAct = CHASr0i / OnBoardRes # adjust resistor value to include switch ron
20326  CHASr100 = CHAVSr100Raw * ( AD584act / CHA584Raw )
20327  CHASrI100Act = (CHASr100 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
20328  CHASrN45 = CHAVSrN45Raw * ( AD584act / CHA584Raw )
20329  CHASrIN45Act = (CHASrN45 - CHA2p5) / OnBoardRes # adjust resistor value to include switch ron
20330  #
20331  CHBSr0i = CHBVSr0iRaw * ( AD584act / CHB584Raw )
20332  CHBSr0iAct = CHBSr0i / OnBoardRes # adjust resistor value to include switch ron
20333  CHBSr100 = CHBVSr100Raw * ( AD584act / CHB584Raw )
20334  CHBSrI100Act = (CHBSr100 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
20335  CHBSrN45 = CHBVSrN45Raw * ( AD584act / CHB584Raw )
20336  CHBSrIN45Act = (CHBSrN45 - CHB2p5) / OnBoardRes # adjust resistor value to include switch ron
20337  # Write cal factors to file
20338  #
20339  CalFile.write('# Channel A, measure V\n')
20340  CalFile.write('</>\n')
20341  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAGndRaw) + '>\n')
20342  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHA584Raw) + '>\n')
20343  CalFile.write('<>\n')
20344  CalFile.write('\n')
20345  #
20346  CalFile.write('# Channel A, measure I\n')
20347  CalFile.write('</>\n')
20348  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAI02p5Raw) + '>\n')
20349  CalFile.write('<' + '{0:.4f}'.format(CHAActSrI) + ', ' + '{0:.4f}'.format(CHAISr5vRaw) + '>\n')
20350  # CalFile.write('<' + '{0:.4f}'.format(CHAISr0vRaw) + ', ' + '{0:.4f}'.format(CHAActSnkI) + '>\n')
20351  CalFile.write('<' + '{0:.4f}'.format(-CHAActSrI) + ', ' + '{0:.4f}'.format(-CHAISr5vRaw) + '>\n')
20352  CalFile.write('<>\n')
20353  CalFile.write('\n')
20354  #
20355  CalFile.write('# Channel A, source V\n')
20356  CalFile.write('</>\n')
20357  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAF0vRaw) + '>\n')
20358  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
20359  CalFile.write('<>\n')
20360  CalFile.write('\n')
20361  #
20362  CalFile.write('# Channel A, source I\n')
20363  CalFile.write('</>\n')
20364  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHAISr0iRaw) + '>\n')
20365  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHASrI100Act) + '>\n')
20366  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHASrIN45Act) + '>\n')
20367  CalFile.write('<>\n')
20368  CalFile.write('\n')
20369  #
20370  CalFile.write('# Channel B, measure V\n')
20371  CalFile.write('</>\n')
20372  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBGndRaw) + '>\n')
20373  CalFile.write('<' + '{0:.4f}'.format(AD584act) + ', ' + '{0:.4f}'.format(CHB584Raw) + '>\n')
20374  CalFile.write('<>\n')
20375  CalFile.write('\n')
20376  #
20377  CalFile.write('# Channel B, measure I\n')
20378  CalFile.write('</>\n')
20379  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBI02p5Raw) + '>\n')
20380  CalFile.write('<' + '{0:.4f}'.format(CHBActSrI) + ', ' + '{0:.4f}'.format(CHBISr5vRaw) + '>\n')
20381  # CalFile.write('<' + '{0:.4f}'.format(CHBISr0vRaw) + ', ' + '{0:.4f}'.format(CHBActSnkI) + '>\n')
20382  CalFile.write('<' + '{0:.4f}'.format(-CHBActSrI) + ', ' + '{0:.4f}'.format(-CHBISr5vRaw) + '>\n')
20383  CalFile.write('<>\n')
20384  CalFile.write('\n')
20385  #
20386  CalFile.write('# Channel B, source V\n')
20387  CalFile.write('</>\n')
20388  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBF0vRaw) + '>\n')
20389  CalFile.write('<4.5000, ' + '{0:.4f}'.format(CHAF25V) + '>\n')
20390  CalFile.write('<>\n')
20391  CalFile.write('\n')
20392  #
20393  CalFile.write('# Channel B source I\n')
20394  CalFile.write('</>\n')
20395  CalFile.write('<0.0000, ' + '{0:.4f}'.format(CHBISr0iRaw) + '>\n')
20396  CalFile.write('<0.045, ' + '{0:.4f}'.format(CHBSrI100Act) + '>\n')
20397  CalFile.write('<-0.0450, ' + '{0:.4f}'.format(CHBSrIN45Act) + '>\n')
20398  CalFile.write('<>\n')
20399  #
20400  CalFile.close()
20401  showinfo("Finish","Successfully measured cal factors!", parent=calwindow)
20402  if askyesno("Write cal", "Write Cal Data to Board?", parent=calwindow):
20403  devx.write_calibration(filename)
20404  #print "wrote new " , filename
20405  #
20406  # session.end()
20407  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
20408  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
20409  contloop = 0
20410  discontloop = 1
20411  # session.cancel()
20412  calwindow.destroy()
20413 #
20415  global cal, DevID, devx
20416 
20417  devidstr = DevID[17:31]
20418  filename = "calib" + devidstr + "test.txt"
20419  if os.path.isfile(filename):
20420  if askyesno("Calibration exists", "A previous Calibration file exists. /n Do you want to load that?"): #, parent=calwindow):
20421  return
20422  else:
20423  if askyesno("Continue?", "Continure with save calibration file?"): #, parent=calwindow):
20424  donothing()
20425  else:
20426  calwindow.destroy()
20427  return
20428  #
20429  CalFile = open(filename, "w")
20430  #
20431  # Write cal factors to file
20432  # [0]
20433  CalFile.write('# Channel A, measure V\n')
20434  CalFile.write('</>\n')
20435  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[0][0]) + '>\n')
20436  CHAgp = (5.0/cal[0][1])+cal[0][0]
20437  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20438  CalFile.write('<>\n')
20439  CalFile.write('\n')
20440  # [1]
20441  CalFile.write('# Channel A, measure I\n')
20442  CalFile.write('</>\n')
20443  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[1][0]) + '>\n')
20444  CHAgp = (0.1/cal[0][1])+cal[1][0]
20445  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20446  CHAgn = (-0.1/cal[0][2])+cal[1][0]
20447  CalFile.write('<-0.1000' + '{0:.5f}'.format(CHAgn) + '>\n')
20448  CalFile.write('<>\n')
20449  CalFile.write('\n')
20450  # [2]
20451  CalFile.write('# Channel A, source V\n')
20452  CalFile.write('</>\n')
20453  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[2][0]) + '>\n')
20454  CHAgp = (5.0/cal[2][1])+cal[2][0]
20455  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20456  CalFile.write('<>\n')
20457  CalFile.write('\n')
20458  # [3]
20459  CalFile.write('# Channel A, source I\n')
20460  CalFile.write('</>\n')
20461  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[3][0]) + '>\n')
20462  CHAgp = (0.1/cal[3][1])+cal[3][0]
20463  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20464  CHAgn = (-0.1/cal[3][2])+cal[3][0]
20465  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20466  CalFile.write('<>\n')
20467  CalFile.write('\n')
20468  # [4]
20469  CalFile.write('# Channel B, measure V\n')
20470  CalFile.write('</>\n')
20471  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[4][0]) + '>\n')
20472  CHAgp = (5.0/cal[4][1])+cal[4][0]
20473  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20474  CalFile.write('<>\n')
20475  CalFile.write('\n')
20476  # [5]
20477  CalFile.write('# Channel B, measure I\n')
20478  CalFile.write('</>\n')
20479  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[5][0]) + '>\n')
20480  CHAgp = (0.1/cal[5][1])+cal[5][0]
20481  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20482  CHAgn = (-0.1/cal[5][2])+cal[5][0]
20483  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20484  CalFile.write('<>\n')
20485  CalFile.write('\n')
20486  # [6]
20487  CalFile.write('# Channel B, source V\n')
20488  CalFile.write('</>\n')
20489  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[6][0]) + '>\n')
20490  CHAgp = (5.0/cal[6][1])+cal[6][0]
20491  CalFile.write('<5.0000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20492  CalFile.write('<>\n')
20493  CalFile.write('\n')
20494  # [7]
20495  CalFile.write('# Channel B source I\n')
20496  CalFile.write('</>\n')
20497  CalFile.write('<0.0000, ' + '{0:.5f}'.format(cal[7][0]) + '>\n')
20498  CHAgp = (0.1/cal[7][1])+cal[7][0]
20499  CalFile.write('<0.1000, ' + '{0:.5f}'.format(CHAgp) + '>\n')
20500  CHAgn = (-0.1/cal[7][2])+cal[7][0]
20501  CalFile.write('<-0.1000, ' + '{0:.5f}'.format(CHAgn) + '>\n')
20502  CalFile.write('<>\n')
20503  #
20504  CalFile.close()
20505 
20507 def SPIShiftOut(DValue):
20508  global devx, PIO_0, PIO_1, PIO_2, PIO_3, SCLKPort, SDATAPort, SLATCHPort
20509 
20510  binstr = bin(DValue)
20511  binlen = len(binstr)
20512  datastr = binstr[2:binlen]
20513  datalen = len(datastr)
20514  if datalen < 16:
20515  datastr = str.rjust(datastr , 16 , '0')
20516  datalen = len(datastr)
20517  i = 1
20518  devx.ctrl_transfer(0x40, 0x50, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 0
20519  while i < datalen+1:
20520  # sending 0x50 = set to 0, 0x51 = set to 1
20521  D1code = 0x50 + int(datastr[i-1])
20522  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
20523  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
20524  devx.ctrl_transfer(0x40, 0x50, SCLKPort.get(), 0, 0, 0, 100) # sclk to 0
20525  devx.ctrl_transfer(0x40, 0x51, SCLKPort.get(), 0, 0, 0, 100) # sclk to 1
20526  i = i + 1
20527  devx.ctrl_transfer(0x40, 0x51, SLATCHPort.get(), 0, 0, 0, 100) # fsync to 1
20528 #
20529 def SetAD9833(temp):
20530  global FminEntry, HtMulEntry, MinigenFout, MinigenMode, etssrlab, EnableMinigenMode # , Fclk, Fout
20531  global Two28, mclk, EnableHSsampling, MinigenScreenStatus, ETSts, Two_X_Sample
20532 
20533  #
20534  if MinigenScreenStatus.get() == 0:
20535  #SRstring = "ET Sample Rate = " + str(SAMPLErate*MulX)
20536  #etssrlab.config(text=SRstring)
20537  return
20538  #
20539  if EnableMinigenMode == 2:
20540  MinigenMode.set(40)
20541  #
20542  try:
20543  FminE = float(eval(FminEntry.get()))*1000
20544  except:
20545  if EnableHSsampling > 0:
20546  FminEntry.delete(0,END)
20547  FminEntry.insert(0, FminE/1000)
20548  if MulX == 1:
20549  Fmin = FminE
20550  else:
20551  Fmin = FminE - (FminE/MulX)
20552  #
20553  MinigenFout.delete(0,"end")
20554  MinigenFout.insert(0,Fmin)
20555  #
20556  BSendMG()
20557 
20559 def BSendMG():
20560  global MinigenFclk, MinigenFout, MinigenMode
20561  global Two28, SCLKPort, SDATAPort, SLATCHPort
20562 
20563  DValue = 8192 + MinigenMode.get()
20564  SPIShiftOut(DValue)
20565  try:
20566  fout = float(eval(MinigenFout.get()))
20567  except:
20568  MinigenFout.delete(0,"end")
20569  MinigenFout.insert(0,100)
20570  try:
20571  mclk = float(eval(MinigenFclk.get()))*1000000 # convert from MHz to Hz
20572  except:
20573  MingenFclk.delete(0,"end")
20574  MinigenFclk.insert(0,16)
20575  Freg = int((fout*Two28)/mclk)
20576  Foutstr = bin(Freg)
20577  Foutlen = len(Foutstr)
20578  datastr = Foutstr[2:Foutlen]
20579  datalen = len(datastr)
20580  if datalen < 28:
20581  datastr = str.rjust(datastr , 28 , '0')
20582  datalen = len(datastr)
20583  Fmsb = '0b01' + datastr[0:14]
20584  Flsb = '0b01' + datastr[14:]
20585  FValue = int(eval(Flsb))
20586  SPIShiftOut(FValue)
20587  FValue = int(eval(Fmsb))
20588  SPIShiftOut(FValue)
20589 
20592  global RevDate, minigenwindow, MinigenMode, MinigenScreenStatus, MinigenFclk, MinigenFout, SWRev
20593  global SCLKPort, SDATAPort, SLATCHPort
20594  global GenericSerialStatus
20595  global PIO_0, PIO_1, PIO_2, PIO_3
20596 
20597  if GenericSerialStatus.get() == 1:
20598  GenericSerialStatus.set(0)
20600  if MinigenScreenStatus.get() == 0:
20601  MinigenScreenStatus.set(1)
20602  minigenwindow = Toplevel()
20603  minigenwindow.title("-AD983x DDS- " + SWRev + RevDate)
20604  minigenwindow.resizable(FALSE,FALSE)
20605  minigenwindow.protocol("WM_DELETE_WINDOW", DestroyMinigenScreen)
20606  #
20607  MinigenMode = IntVar(0)
20608  mgb1 = Radiobutton(minigenwindow, text="Sine", variable=MinigenMode, value=0, command=BSendMG )
20609  mgb1.grid(row=1, column=0, sticky=W)
20610  mgb2 = Radiobutton(minigenwindow, text="Triangle", variable=MinigenMode, value=2, command=BSendMG )
20611  mgb2.grid(row=1, column=1, columnspan=2, sticky=W)
20612  mgb3 = Radiobutton(minigenwindow, text="Square", variable=MinigenMode, value=40, command=BSendMG )
20613  mgb3.grid(row=2, column=0, sticky=W)
20614  mgb4 = Radiobutton(minigenwindow, text="Square/2", variable=MinigenMode, value=32, command=BSendMG )
20615  mgb4.grid(row=2, column=1, columnspan=2, sticky=W)
20616  f0lab = Label(minigenwindow, text="Mclk in MHz")
20617  f0lab.grid(row=3, column=0, columnspan=2, sticky=W)
20618  MinigenFclk = Entry(minigenwindow, width=5)
20619  MinigenFclk.grid(row=3, column=1, columnspan=2, sticky=W, padx=6)
20620  MinigenFclk.delete(0,"end")
20621  MinigenFclk.insert(0,16)
20622  f1lab = Label(minigenwindow, text="Output Freq")
20623  f1lab.grid(row=4, column=0, columnspan=2, sticky=W)
20624  MinigenFout = Entry(minigenwindow, width=8, cursor='double_arrow')
20625  MinigenFout.bind('<MouseWheel>', onMiniGenScroll)
20626  MinigenFout.bind("<Button-4>", onMiniGenScroll)# with Linux OS
20627  MinigenFout.bind("<Button-5>", onMiniGenScroll)
20628  MinigenFout.grid(row=4, column=1, columnspan=2, sticky=W)
20629  MinigenFout.delete(0,"end")
20630  MinigenFout.insert(0,100)
20631  bsn1 = Button(minigenwindow, text='UpDate', style="W7.TButton", command=BSendMG)
20632  bsn1.grid(row=5, column=0, sticky=W, pady=4)
20633  dismissmgbutton = Button(minigenwindow, text="Dismiss", style="W8.TButton", command=DestroyMinigenScreen)
20634  dismissmgbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
20635  #
20636  label3 = Label(minigenwindow,text="SCLK PI/O Port ")
20637  label3.grid(row=6, column=0, sticky=W)
20638  sclk1 = Radiobutton(minigenwindow, text="0", variable=SCLKPort, value=PIO_0)
20639  sclk1.grid(row=6, column=1, sticky=W)
20640  sclk2 = Radiobutton(minigenwindow, text="1", variable=SCLKPort, value=PIO_1)
20641  sclk2.grid(row=6, column=2, sticky=W)
20642  sclk3 = Radiobutton(minigenwindow, text="2", variable=SCLKPort, value=PIO_2)
20643  sclk3.grid(row=6, column=3, sticky=W)
20644  sclk4 = Radiobutton(minigenwindow, text="3", variable=SCLKPort, value=PIO_3)
20645  sclk4.grid(row=6, column=4, sticky=W)
20646  #
20647  label4 = Label(minigenwindow,text="SData PI/O Port ")
20648  label4.grid(row=7, column=0, sticky=W)
20649  sdat1 = Radiobutton(minigenwindow, text="0", variable=SDATAPort, value=PIO_0)
20650  sdat1.grid(row=7, column=1, sticky=W)
20651  sdat2 = Radiobutton(minigenwindow, text="1", variable=SDATAPort, value=PIO_1)
20652  sdat2.grid(row=7, column=2, sticky=W)
20653  sdat3 = Radiobutton(minigenwindow, text="2", variable=SDATAPort, value=PIO_2)
20654  sdat3.grid(row=7, column=3, sticky=W)
20655  sdat4 = Radiobutton(minigenwindow, text="3", variable=SDATAPort, value=PIO_3)
20656  sdat4.grid(row=7, column=4, sticky=W)
20657  #
20658  label5 = Label(minigenwindow,text="FSync PI/O Port ")
20659  label5.grid(row=8, column=0, sticky=W)
20660  slth1 = Radiobutton(minigenwindow, text="0", variable=SLATCHPort, value=PIO_0)
20661  slth1.grid(row=8, column=1, sticky=W)
20662  slth2 = Radiobutton(minigenwindow, text="1", variable=SLATCHPort, value=PIO_1)
20663  slth2.grid(row=8, column=2, sticky=W)
20664  slth3 = Radiobutton(minigenwindow, text="2", variable=SLATCHPort, value=PIO_2)
20665  slth3.grid(row=8, column=3, sticky=W)
20666  slth4 = Radiobutton(minigenwindow, text="3", variable=SLATCHPort, value=PIO_3)
20667  slth4.grid(row=8, column=4, sticky=W)
20668  #
20669 
20672  global minigenwindow, MinigenScreenStatus
20673 
20674  MinigenScreenStatus.set(0)
20675  minigenwindow.destroy()
20676 #
20677 def onMiniGenScroll(event):
20678  global ETSStatus, ETSDisp
20679 
20680  onTextScroll(event)
20681  BSendMG()
20682 
20684 def DA1ShiftOut(D1Value, D2Value):
20685  global devx
20686  global PIO_0, PIO_1, PIO_2, PIO_3
20687 
20688  binstr = bin(D1Value)
20689  binlen = len(binstr)
20690  data1str = binstr[2:binlen]
20691  datalen = len(data1str)
20692  if datalen < 16:
20693  data1str = str.rjust(data1str , 16 , '0')
20694  datalen = len(data1str)
20695  #
20696  binstr = bin(D2Value)
20697  binlen = len(binstr)
20698  data2str = binstr[2:binlen]
20699  datalen = len(data2str)
20700  if datalen < 16:
20701  data2str = str.rjust(data2str , 16 , '0')
20702  datalen = len(data2str)
20703  # sync --> PIO 0
20704  # D0 --> PIO 1
20705  # D1 --> PIO 2
20706  # SCLK --> PIO 3
20707  i = 1
20708 #
20709  devx.ctrl_transfer(0x40, 0x50, 0, 0, 0, 0, 100) # sync to 0
20710  while i < datalen+1:
20711  # sending 0x50 = set to 0, 0x51 = set to 1
20712  D1code = 0x50 + int(data1str[i-1])
20713  D2code = 0x50 + int(data2str[i-1])
20714  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data 0 bit
20715  devx.ctrl_transfer(0x40, D2code, PIO_2, 0, 0, 0, 100) # data 1 bit
20716  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
20717  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # sclk to 0
20718  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # sclk to 1
20719  i = i + 1
20720  devx.ctrl_transfer(0x40, 0x51, PIO_0, 0, 0, 0, 100) # sync to 1
20721  #
20722 def BSendDA1():
20723  global DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry, REFEntry
20724 
20725  try:
20726  RefValue = float(eval(REFEntry.get()))
20727  except:
20728  RefValue = 3.3
20729  try:
20730  D1Value = float(eval(DAC1Entry.get()))
20731  except:
20732  D1Value = 0.0129
20733  D1Code = int((D1Value/RefValue)*255)
20734  if D1Code > 255:
20735  D1Code = 255
20736  D1Code = D1Code + 0x2000
20737  try:
20738  D2Value = float(eval(DAC2Entry.get()))
20739  except:
20740  D2Value = 0.0129
20741  D2Code = int((D2Value/RefValue)*255)
20742  if D2Code > 255:
20743  D2Code = 255
20744  D2Code = D2Code + 0x2400
20745  try:
20746  D3Value = float(eval(DAC3Entry.get()))
20747  except:
20748  D3Value = 0.0129
20749  D3Code = int((D3Value/RefValue)*255)
20750  if D3Code > 255:
20751  D3Code = 255
20752  D3Code = D3Code + 0x2000
20753  try:
20754  D4Value = float(eval(DAC4Entry.get()))
20755  except:
20756  D4Value = 0.0129
20757  D4Code = int((D4Value/RefValue)*255)
20758  if D4Code > 255:
20759  D4Code = 255
20760  D4Code = D4Code + 0x2400
20761  #
20762  DA1ShiftOut(D1Code, D3Code)
20763  DA1ShiftOut(D2Code, D4Code)
20764 
20767  global da1window, DA1ScreenStatus, DAC1Entry, DAC2Entry, DAC3Entry, DAC4Entry
20768  global REFEntry, RevDate, SWRev
20769 
20770  if DA1ScreenStatus.get() == 0:
20771  DA1ScreenStatus.set(1)
20772  da1window = Toplevel()
20773  da1window.title("-DA1 PMOD- " + SWRev + RevDate)
20774  da1window.resizable(FALSE,FALSE)
20775  da1window.protocol("WM_DELETE_WINDOW", DestroyDA1Screen)
20776 #
20777  d1lab = Label(da1window, text="DAC A1 output")
20778  d1lab.grid(row=0, column=0, columnspan=1, sticky=W)
20779  DAC1Entry = Entry(da1window, width=5)
20780  DAC1Entry.grid(row=0, column=1, sticky=W)
20781  DAC1Entry.delete(0,"end")
20782  DAC1Entry.insert(0,0)
20783  d2lab = Label(da1window, text="DAC B1 output")
20784  d2lab.grid(row=1, column=0, columnspan=1, sticky=W)
20785  DAC2Entry = Entry(da1window, width=5)
20786  DAC2Entry.grid(row=1, column=1, sticky=W)
20787  DAC2Entry.delete(0,"end")
20788  DAC2Entry.insert(0,0)
20789 
20790  d3lab = Label(da1window, text="DAC A2 output")
20791  d3lab.grid(row=2, column=0, columnspan=1, sticky=W)
20792  DAC3Entry = Entry(da1window, width=5)
20793  DAC3Entry.grid(row=2, column=1, sticky=W)
20794  DAC3Entry.delete(0,"end")
20795  DAC3Entry.insert(0,0)
20796 
20797  d4lab = Label(da1window, text="DAC B2 output")
20798  d4lab.grid(row=3, column=0, columnspan=1, sticky=W)
20799  DAC4Entry = Entry(da1window, width=5)
20800  DAC4Entry.grid(row=3, column=1, sticky=W)
20801  DAC4Entry.delete(0,"end")
20802  DAC4Entry.insert(0,0)
20803 
20804  d5lab = Label(da1window, text="Reference V")
20805  d5lab.grid(row=4, column=0, columnspan=1, sticky=W)
20806  REFEntry = Entry(da1window, width=5)
20807  REFEntry.grid(row=4, column=1, sticky=W)
20808  REFEntry.delete(0,"end")
20809  REFEntry.insert(0,3.3)
20810 
20811  bsn1 = Button(da1window, text='UpDate', style="W7.TButton", command=BSendDA1)
20812  bsn1.grid(row=5, column=0, sticky=W)
20813  dismissdabutton = Button(da1window, text="Dismiss", style="W8.TButton", command=DestroyDA1Screen)
20814  dismissdabutton.grid(row=5, column=1, sticky=W, pady=4)
20815 
20818  global da1window, DA1ScreenStatus
20819 
20820  DA1ScreenStatus.set(0)
20821  da1window.destroy()
20822 
20823 def DigPotShiftOut(DValue):
20824  global devx, SingleDualPot
20825  global PIO_0, PIO_1, PIO_2, PIO_3
20826 
20827  binstr = bin(DValue)
20828  binlen = len(binstr)
20829  datastr = binstr[2:binlen]
20830  datalen = len(datastr)
20831  if SingleDualPot.get() == 0: # send 10 bits of data
20832  if datalen < 10:
20833  datastr = str.rjust(datastr , 10 , '0')
20834  datalen = len(datastr)
20835  if SingleDualPot.get() == 1: # send 8 bits of data
20836  if datalen < 8:
20837  datastr = str.rjust(datastr , 8 , '0')
20838  datalen = len(datastr)
20839  if SingleDualPot.get() == 2: # send 8 bits of data
20840  if datalen < 8:
20841  datastr = str.rjust(datastr , 8 , '0')
20842  datalen = len(datastr)
20843  i = 1
20844  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
20845  devx.ctrl_transfer(0x40, 0x50, PIO_0, 0, 0, 0, 100) # CS to 0
20846  while i < datalen+1:
20847  # CS --> PIO 0
20848  # D0 --> PIO 1
20849  # D1 --> PIO 2
20850  # SCLK --> PIO 3
20851  D1code = 0x50 + int(datastr[i-1])
20852  devx.ctrl_transfer(0x40, D1code, PIO_1, 0, 0, 0, 100) # data bit
20853  devx.ctrl_transfer(0x40, 0x51, PIO_3, 0, 0, 0, 100) # clock to 1
20854  devx.ctrl_transfer(0x40, 0x50, PIO_3, 0, 0, 0, 100) # clock to 0
20855  i = i + 1
20856  devx.ctrl_transfer(0x40, 0x51, 0, 0, 0, 0, 100) # CS to 1
20857  #
20858 def DigPotSend(Temp):
20859  global DigPot1, DigPot2, DigPot3, DigPot4, SendPot1, SendPot2, SendPot3, SendPot4
20860  global SingleDualPot
20861 
20862  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
20863  NumTaps = 255
20864  if SingleDualPot.get() == 2:
20865  NumTaps = 63
20866  try:
20867  DValue1 = DigPot1.get()
20868  if DValue1 > NumTaps:
20869  DValue1 = NumTaps
20870  except:
20871  DValue1 = 0
20872  try:
20873  DValue2 = DigPot2.get()
20874  if DValue2 > NumTaps:
20875  DValue2 = NumTaps
20876  except:
20877  DValue2 = 0
20878  try:
20879  DValue3 = DigPot3.get()
20880  if DValue3 > NumTaps:
20881  DValue3 = NumTaps
20882  except:
20883  DValue3 = 0
20884  try:
20885  DValue4 = DigPot4.get()
20886  if DValue4 > NumTaps:
20887  DValue4 = NumTaps
20888  except:
20889  DValue4 = 0
20890  if SendPot1.get() > 0:
20891  DigPotShiftOut(DValue1)
20892  if SendPot2.get() > 0:
20893  DigPotShiftOut(DValue2+NumTaps+1)
20894  if SendPot3.get() > 0:
20895  DigPotShiftOut(DValue3+2*(NumTaps+1))
20896  if SendPot4.get() > 0:
20897  DigPotShiftOut(DValue4+3*(NumTaps+1))
20898 
20900  global SingleDualPot, DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
20901 
20902  if SingleDualPot.get() == 0 or SingleDualPot.get() == 1:
20903  DPotlabel.config(text="Enter number from 0 to 255")
20904  DigPot1.config(from_=0, to=255, length=256)
20905  DigPot2.config(from_=0, to=255, length=256)
20906  DigPot3.config(from_=0, to=255, length=256)
20907  DigPot4.config(from_=0, to=255, length=256)
20908  if SingleDualPot.get() == 2:
20909  DPotlabel.config(text="Enter number from 0 to 63")
20910  DigPot1.config(from_=0, to=63, length=64)
20911  DigPot2.config(from_=0, to=63, length=64)
20912  DigPot3.config(from_=0, to=63, length=64)
20913  DigPot4.config(from_=0, to=63, length=64)
20914 
20917  global digpotwindow, DigPotScreenStatus, DigPot1, DigPot2, DigPot3, DigPot4, RevDate
20918  global SendPot1, SendPot2, SendPot3, SendPot4, SingleDualPot, SWRev
20919  global DPotlabel, DigPot1, DigPot2, DigPot3, DigPot4
20920 
20921  if DigPotScreenStatus.get() == 0:
20922  DigPotScreenStatus.set(1)
20923  digpotwindow = Toplevel()
20924  digpotwindow.title("Digital Potentiometer " + SWRev + RevDate)
20925  digpotwindow.resizable(FALSE,FALSE)
20926  digpotwindow.protocol("WM_DELETE_WINDOW", DestroyDigPotScreen)
20927  #
20928  SendPot1 = IntVar(0)
20929  SendPot1.set(1)
20930  SendPot2 = IntVar(0)
20931  SendPot2.set(1)
20932  SendPot3 = IntVar(0)
20933  SendPot3.set(0)
20934  SendPot4 = IntVar(0)
20935  SendPot4.set(0)
20936  DPotlabel = Label(digpotwindow,text="Enter number from 0 to 255", style="A12B.TLabel")
20937  DPotlabel.grid(row=0, column=0, columnspan=3, sticky=W)
20938 
20939  SingleDualPot = IntVar(0)
20940  SingleDualPot.set(0)
20941  CompMenu = Menubutton(digpotwindow, text="Sel Comp.", style="W8.TButton")
20942  CompMenu.menu = Menu(CompMenu, tearoff = 0 )
20943  CompMenu["menu"] = CompMenu.menu
20944  CompMenu.menu.add_radiobutton(label="AD840X", variable=SingleDualPot, value=0, command=UpdatePotSlider)
20945  CompMenu.menu.add_radiobutton(label="AD5160", variable=SingleDualPot, value=1, command=UpdatePotSlider)
20946  CompMenu.menu.add_radiobutton(label="AD5203", variable=SingleDualPot, value=2, command=UpdatePotSlider)
20947  CompMenu.grid(row=1, column=0, columnspan=2, sticky=W)
20948  lab1 = Checkbutton(digpotwindow,text="Pot 1", variable=SendPot1)
20949  lab1.grid(row=2, column=0, sticky=W)
20950  DigPot1 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
20951  DigPot1.grid(row=3, column=0, columnspan=3, sticky=W)
20952  lab2 = Checkbutton(digpotwindow,text="Pot 2", variable=SendPot2)
20953  lab2.grid(row=4, column=0, sticky=W)
20954  DigPot2 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
20955  DigPot2.grid(row=5, column=0, columnspan=3, sticky=W)
20956  lab3 = Checkbutton(digpotwindow,text="Pot 3", variable=SendPot3)
20957  lab3.grid(row=6, column=0, sticky=W)
20958  DigPot3 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
20959  DigPot3.grid(row=7, column=0, columnspan=3, sticky=W)
20960  lab4 = Checkbutton(digpotwindow,text="Pot 4", variable=SendPot4)
20961  lab4.grid(row=8, column=0, sticky=W)
20962  DigPot4 = Scale(digpotwindow, from_=0, to=255, orient=HORIZONTAL, command=DigPotSend, length=256)
20963  DigPot4.grid(row=9, column=0, columnspan=3, sticky=W)
20964  dismissdpbutton = Button(digpotwindow, text="Dismiss", style="W8.TButton", command=DestroyDigPotScreen)
20965  dismissdpbutton.grid(row=10, column=0, sticky=W, pady=4)
20966 
20968  global digpotwindow, DigPotScreenStatus
20969 
20970  DigPotScreenStatus.set(0)
20971  digpotwindow.destroy()
20972 
20973 def BSendGS():
20974  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
20975  global NumBitsEntry, DataBitsEntry, devx, SerDirection, DValue, NumBits, AD5626SerialStatus, AD5626Entry
20976 
20977  if AD5626SerialStatus.get() == 0:
20978  try:
20979  DValue = int(eval(DataBitsEntry.get()))
20980  if DValue < 0:
20981  DValue = 0
20982  except:
20983  DValue = 0
20984  try:
20985  NumBits = int(NumBitsEntry.get())
20986  if NumBits < 1:
20987  NumBits = 1
20988  except:
20989  NumBits = 8
20990  else:
20991  try:
20992  DValue = int(eval(AD5626Entry.get())*1000)
20993  if DValue < 0:
20994  DValue = 0
20995  AD5626Entry.delete(0,"end")
20996  AD5626Entry.insert(0,'0.000')
20997  if DValue > 4095:
20998  DValue = 4095
20999  AD5626Entry.delete(0,"end")
21000  AD5626Entry.insert(0,DValue/1000.0)
21001  except:
21002  DValue = 0
21003  AD5626Entry.delete(0,"end")
21004  AD5626Entry.insert(0,'0.000')
21005  NumBits = 12
21006  # print DValue
21007  binstr = bin(DValue)
21008  binlen = len(binstr)
21009  datastr = binstr[2:binlen]
21010  datalen = len(datastr)
21011  if datalen < NumBits:
21012  datastr = str.rjust(datastr , NumBits , '0')
21013  datalen = len(datastr)
21014  if SLatchPhase.get() == 0:
21015  LatchInt = 0x50
21016  LatchEnd = 0x51
21017  else:
21018  LatchInt = 0x51
21019  LatchEnd = 0x50
21020  if AD5626SerialStatus.get() > 0:
21021  LatchInt = 0x51
21022  LatchEnd = 0x50
21023  if SClockPhase.get() == 0:
21024  ClockInt = 0x50
21025  ClockEnd = 0x51
21026  else:
21027  ClockInt = 0x51
21028  ClockEnd = 0x50
21029  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21030  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21031  i = 1
21032  while i < datalen+1:
21033  if SerDirection.get() == 1: # for MSB first
21034  D1code = 0x50 + int(datastr[datalen-i]) # 0x50 = set to 0, 0x51 = set to 1
21035  else:
21036  D1code = 0x50 + int(datastr[i-1]) # for LSB first
21037  devx.ctrl_transfer(0x40, D1code, SDATAPort.get(), 0, 0, 0, 100) # data bit
21038  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21039  devx.ctrl_transfer(0x40, ClockInt, SCLKPort.get(), 0, 0, 0, 100) # clock to start value
21040  i = i + 1
21041  devx.ctrl_transfer(0x40, ClockEnd, SCLKPort.get(), 0, 0, 0, 100) # clock to end value
21042  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21043  devx.ctrl_transfer(0x40, LatchInt, SLATCHPort.get(), 0, 0, 0, 100) # CS to start value
21044  devx.ctrl_transfer(0x40, LatchEnd, SLATCHPort.get(), 0, 0, 0, 100) # CS to end value
21045 
21048  global ad5626window, AD5626SerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21049  global GenericSerialStatus, AD5626Entry, SerDirection, SWRev
21050  global PIO_0, PIO_1, PIO_2, PIO_3
21051 
21052  if GenericSerialStatus.get() == 1:
21053  GenericSerialStatus.set(0)
21055  if AD5626SerialStatus.get() == 0:
21056  AD5626SerialStatus.set(1)
21057  ad5626window = Toplevel()
21058  ad5626window.title("AD5626 Output " + SWRev + RevDate)
21059  ad5626window.resizable(FALSE,FALSE)
21060  ad5626window.protocol("WM_DELETE_WINDOW", DestroyAD5626Screen)
21061 #
21062  SLatchPhase = IntVar(0)
21063  SLatchPhase.set(0)
21064  SClockPhase = IntVar(0)
21065  SClockPhase.set(1)
21066  SerDirection = IntVar(0)
21067  SerDirection.set(0)
21068  #
21069  label2 = Label(ad5626window,text="Enter Output Volts")
21070  label2.grid(row=1, column=0, columnspan=1, sticky=W)
21071  AD5626Entry = Entry(ad5626window, width=10, cursor='double_arrow')
21072  AD5626Entry.bind('<MouseWheel>', onAD5626Scroll)
21073  AD5626Entry.bind("<Button-4>", onAD5626Scroll)# with Linux OS
21074  AD5626Entry.bind("<Button-5>", onAD5626Scroll)
21075  AD5626Entry.grid(row=1, column=1, columnspan=3, sticky=W)
21076  AD5626Entry.delete(0,"end")
21077  AD5626Entry.insert(0,'0.000')
21078  #
21079  label3 = Label(ad5626window,text="SCLK PI/O Port ")
21080  label3.grid(row=2, column=0, columnspan=1, sticky=W)
21081  sclk1 = Radiobutton(ad5626window, text="0", variable=SCLKPort, value=PIO_0)
21082  sclk1.grid(row=2, column=1, sticky=W)
21083  sclk2 = Radiobutton(ad5626window, text="1", variable=SCLKPort, value=PIO_1)
21084  sclk2.grid(row=2, column=2, sticky=W)
21085  sclk3 = Radiobutton(ad5626window, text="2", variable=SCLKPort, value=PIO_2)
21086  sclk3.grid(row=2, column=3, sticky=W)
21087  sclk4 = Radiobutton(ad5626window, text="3", variable=SCLKPort, value=PIO_3)
21088  sclk4.grid(row=2, column=4, sticky=W)
21089  #
21090  label4 = Label(ad5626window,text="SData PI/O Port ")
21091  label4.grid(row=3, column=0, columnspan=1, sticky=W)
21092  sdat1 = Radiobutton(ad5626window, text="0", variable=SDATAPort, value=PIO_0)
21093  sdat1.grid(row=3, column=1, sticky=W)
21094  sdat2 = Radiobutton(ad5626window, text="1", variable=SDATAPort, value=PIO_1)
21095  sdat2.grid(row=3, column=2, sticky=W)
21096  sdat3 = Radiobutton(ad5626window, text="2", variable=SDATAPort, value=PIO_2)
21097  sdat3.grid(row=3, column=3, sticky=W)
21098  sdat4 = Radiobutton(ad5626window, text="3", variable=SDATAPort, value=PIO_3)
21099  sdat4.grid(row=3, column=4, sticky=W)
21100  #
21101  label5 = Label(ad5626window,text="Latch PI/O Port ")
21102  label5.grid(row=4, column=0, columnspan=1, sticky=W)
21103  slth1 = Radiobutton(ad5626window, text="0", variable=SLATCHPort, value=PIO_0)
21104  slth1.grid(row=4, column=1, sticky=W)
21105  slth2 = Radiobutton(ad5626window, text="1", variable=SLATCHPort, value=PIO_1)
21106  slth2.grid(row=4, column=2, sticky=W)
21107  slth3 = Radiobutton(ad5626window, text="2", variable=SLATCHPort, value=PIO_2)
21108  slth3.grid(row=4, column=3, sticky=W)
21109  slth4 = Radiobutton(ad5626window, text="3", variable=SLATCHPort, value=PIO_3)
21110  slth4.grid(row=4, column=4, sticky=W)
21111  #
21112  bsn1 = Button(ad5626window, text='Send', style="W5.TButton", command=BSendGS)
21113  bsn1.grid(row=5, column=0, sticky=W)
21114  dismissgsbutton = Button(ad5626window, text="Dismiss", style="W8.TButton", command=DestroyAD5626Screen)
21115  dismissgsbutton.grid(row=5, column=1, columnspan=2, sticky=W, pady=4)
21116 #
21117 def onAD5626Scroll(event):
21118  onTextScroll(event)
21119  BSendGS()
21120 
21122  global ad5626window, AD5626SerialStatus
21123 
21124  AD5626SerialStatus.set(0)
21125  ad5626window.destroy()
21126 
21128  global serialwindow, GenericSerialStatus, SCLKPort, SDATAPort, SLATCHPort, SLatchPhase, SClockPhase
21129  global NumBitsEntry, DataBitsEntry, SerDirection, RevDate, SWRev
21130  global PIO_0, PIO_1, PIO_2, PIO_3
21131 
21132  if GenericSerialStatus.get() == 0:
21133  GenericSerialStatus.set(1)
21134  serialwindow = Toplevel()
21135  serialwindow.title("Generic Serial Output " + SWRev + RevDate)
21136  serialwindow.resizable(FALSE,FALSE)
21137  serialwindow.protocol("WM_DELETE_WINDOW", DestroyGenericSerialScreen)
21138  #
21139  SCLKPort = IntVar(0)
21140  SCLKPort.set(PIO_2)
21141  SDATAPort = IntVar(0)
21142  SDATAPort.set(PIO_1)
21143  SLATCHPort = IntVar(0)
21144  SLATCHPort.set(PIO_0)
21145  SLatchPhase = IntVar(0)
21146  SClockPhase = IntVar(0)
21147  SerDirection = IntVar(0)
21148  label = Label(serialwindow,text="Enter number of Bits")
21149  label.grid(row=1, column=0, columnspan=2, sticky=W)
21150  NumBitsEntry = Entry(serialwindow, width=3)
21151  NumBitsEntry.grid(row=1, column=2, sticky=W)
21152  NumBitsEntry.delete(0,"end")
21153  NumBitsEntry.insert(0,8)
21154  #
21155  label2 = Label(serialwindow,text="Enter Data Word")
21156  label2.grid(row=2, column=0, columnspan=1, sticky=W)
21157  DataBitsEntry = Entry(serialwindow, width=10)
21158  DataBitsEntry.grid(row=2, column=1, columnspan=3, sticky=W)
21159  DataBitsEntry.delete(0,"end")
21160  DataBitsEntry.insert(0,0)
21161  #
21162  label3 = Label(serialwindow,text="SCLK PI/O Port ")
21163  label3.grid(row=3, column=0, columnspan=1, sticky=W)
21164  sclk1 = Radiobutton(serialwindow, text="0", variable=SCLKPort, value=PIO_0)
21165  sclk1.grid(row=3, column=1, sticky=W)
21166  sclk2 = Radiobutton(serialwindow, text="1", variable=SCLKPort, value=PIO_1)
21167  sclk2.grid(row=3, column=2, sticky=W)
21168  sclk3 = Radiobutton(serialwindow, text="2", variable=SCLKPort, value=PIO_2)
21169  sclk3.grid(row=3, column=3, sticky=W)
21170  sclk4 = Radiobutton(serialwindow, text="3", variable=SCLKPort, value=PIO_3)
21171  sclk4.grid(row=3, column=4, sticky=W)
21172  #
21173  label4 = Label(serialwindow,text="SData PI/O Port ")
21174  label4.grid(row=4, column=0, columnspan=1, sticky=W)
21175  sdat1 = Radiobutton(serialwindow, text="0", variable=SDATAPort, value=PIO_0)
21176  sdat1.grid(row=4, column=1, sticky=W)
21177  sdat2 = Radiobutton(serialwindow, text="1", variable=SDATAPort, value=PIO_1)
21178  sdat2.grid(row=4, column=2, sticky=W)
21179  sdat3 = Radiobutton(serialwindow, text="2", variable=SDATAPort, value=PIO_2)
21180  sdat3.grid(row=4, column=3, sticky=W)
21181  sdat4 = Radiobutton(serialwindow, text="3", variable=SDATAPort, value=PIO_3)
21182  sdat4.grid(row=4, column=4, sticky=W)
21183  #
21184  label5 = Label(serialwindow,text="Latch PI/O Port ")
21185  label5.grid(row=5, column=0, columnspan=1, sticky=W)
21186  slth1 = Radiobutton(serialwindow, text="0", variable=SLATCHPort, value=PIO_0)
21187  slth1.grid(row=5, column=1, sticky=W)
21188  slth2 = Radiobutton(serialwindow, text="1", variable=SLATCHPort, value=PIO_1)
21189  slth2.grid(row=5, column=2, sticky=W)
21190  slth3 = Radiobutton(serialwindow, text="2", variable=SLATCHPort, value=PIO_2)
21191  slth3.grid(row=5, column=3, sticky=W)
21192  slth4 = Radiobutton(serialwindow, text="3", variable=SLATCHPort, value=PIO_3)
21193  slth4.grid(row=5, column=4, sticky=W)
21194  #
21195  label6 = Label(serialwindow,text="Latch Phase ")
21196  label6.grid(row=6, column=0, columnspan=1, sticky=W)
21197  sph1 = Radiobutton(serialwindow, text="0", variable=SLatchPhase, value=0)
21198  sph1.grid(row=6, column=1, sticky=W)
21199  sph2 = Radiobutton(serialwindow, text="1", variable=SLatchPhase, value=1)
21200  sph2.grid(row=6, column=2, sticky=W)
21201  #
21202  label7 = Label(serialwindow,text="Clock Phase ")
21203  label7.grid(row=7, column=0, columnspan=1, sticky=W)
21204  sph7 = Radiobutton(serialwindow, text="0", variable=SClockPhase, value=0)
21205  sph7.grid(row=7, column=1, sticky=W)
21206  sph8 = Radiobutton(serialwindow, text="1", variable=SClockPhase, value=1)
21207  sph8.grid(row=7, column=2, sticky=W)
21208  #
21209  sdir1 = Radiobutton(serialwindow, text="LSB First", variable=SerDirection, value=0 )
21210  sdir1.grid(row=8, column=0, sticky=W)
21211  sdir2 = Radiobutton(serialwindow, text="MSB First", variable=SerDirection, value=1 )
21212  sdir2.grid(row=8, column=1, columnspan=2, sticky=W)
21213 
21214  bsn1 = Button(serialwindow, text='Send', style="W5.TButton", command=BSendGS)
21215  bsn1.grid(row=9, column=0, sticky=W)
21216  dismissgsbutton = Button(serialwindow, text="Dismiss", style="W8.TButton", command=DestroyGenericSerialScreen)
21217  dismissgsbutton.grid(row=9, column=1, columnspan=2, sticky=W, pady=4)
21218 
21220  global serialwindow, GenericSerialStatus
21221 
21222  GenericSerialStatus.set(0)
21223  serialwindow.destroy()
21224 
21227  global digfltwindow, DigFiltStatus, RevDate, SWRev, DeBugMode
21228  global DigFiltA, DigFiltB, DifFiltALength, DifFiltBLength, DifFiltAFile, DifFiltBFile
21229  global DigFiltABoxCar, DigFiltBBoxCar, BCALenEntry, BCBLenEntry
21230  global BCASkewEntry, BCBSkewEntry, DigDeSkewA, DigDeSkewB
21231  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, AWGFiltAFile
21232  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength, AWGFiltBFile
21233 
21234  if DigFiltStatus.get() == 0:
21235  DigFiltStatus.set(1)
21236  digfltwindow = Toplevel()
21237  digfltwindow.title("Digital Filter " + SWRev + RevDate)
21238  digfltwindow.resizable(FALSE,FALSE)
21239  digfltwindow.protocol("WM_DELETE_WINDOW", DestroyDigFiltScreen)
21240  #
21241  scriptbutton = Button(digfltwindow, text="Run Script", style="W11.TButton", command=RunScript)
21242  scriptbutton.grid(row=0, column=0, columnspan=1, sticky=W)
21243  dismissdfbutton = Button(digfltwindow, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
21244  dismissdfbutton.grid(row=0, column=1, columnspan=1, sticky=W)
21245  frame2 = LabelFrame(digfltwindow, text="CH A Filter", style="A10R1.TLabelframe")
21246  frame3 = LabelFrame(digfltwindow, text="CH B Filter", style="A10R2.TLabelframe")
21247  #frame2.pack(side=LEFT, expand=1, fill=X)
21248  #frame3.pack(side=LEFT, expand=1, fill=X)
21249  frame2.grid(row=1, column=0, sticky=W)
21250  frame3.grid(row=1, column=1, sticky=W)
21251  frame4 = LabelFrame(digfltwindow, text="AWG A Filter", style="A10R1.TLabelframe")
21252  frame5 = LabelFrame(digfltwindow, text="AWG B Filter", style="A10R2.TLabelframe")
21253  frame4.grid(row=2, column=0, sticky=W)
21254  frame5.grid(row=2, column=1, sticky=W)
21255  #
21256  digfilta = Frame( frame2 )
21257  digfilta.pack(side=LEFT)
21258  #titlab = Label(digfltwindow,text="Apply Digital Filters ", style="A12B.TLabel")
21259  #titlab.grid(row=0, column=0, sticky=W)
21260  lab1 = Checkbutton(digfilta,text="Filter CH A", variable=DigFiltA)
21261  lab1.grid(row=0, column=0, columnspan=2, sticky=W)
21262  lab3 = Checkbutton(digfilta,text="Box Car", variable=DigFiltABoxCar, command=BuildBoxCarA)
21263  lab3.grid(row=1, column=0, sticky=W)
21264  BCALenEntry = Entry(digfilta, width=3, cursor='double_arrow')
21265  BCALenEntry.bind("<Return>", onRetDigFiltA)
21266  BCALenEntry.bind('<MouseWheel>', onDigFiltAScroll)
21267  BCALenEntry.bind("<Button-4>", onDigFiltAScroll)# with Linux OS
21268  BCALenEntry.bind("<Button-5>", onDigFiltAScroll)
21269  # BCALenEntry.bind('<Key>', onTextKey)
21270  BCALenEntry.grid(row=1, column=1, sticky=W)
21271  BCALenEntry.delete(0,"end")
21272  BCALenEntry.insert(0,2)
21273  bcalab = Label(digfilta, text="Length")
21274  bcalab.grid(row=1, column=2, sticky=W)
21275  DifFiltALength = Label(digfilta, text="Length = 0 ")
21276  DifFiltALength.grid(row=2, column=0, sticky=W)
21277  DifFiltAFile = Label(digfilta, text="File Name, none ")
21278  DifFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
21279  cald = Button(digfilta, text='Load CH A Filter Coef', command=BLoadDFiltA)
21280  cald.grid(row=4, column=0, columnspan=3, sticky=W)
21281  camath = Button(digfilta, text='CH A Filter formula', command=BDFiltAMath)
21282  camath.grid(row=5, column=0, columnspan=3, sticky=W)
21283 
21284  # Deskew controls
21285  lab5 = Checkbutton(digfilta, text="DeSkew A", variable=DigDeSkewA)# , command=BuildBoxCarA)
21286  lab5.grid(row=6, column=0, sticky=W)
21287  BCASkewEntry = Entry(digfilta, width=3, cursor='double_arrow')
21288  BCASkewEntry.bind('<MouseWheel>', onTextScroll)
21289  BCASkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21290  BCASkewEntry.bind("<Button-5>", onTextScroll)
21291  BCASkewEntry.grid(row=6, column=1, sticky=W)
21292  BCASkewEntry.delete(0,"end")
21293  BCASkewEntry.insert(0,0)
21294  bcasklab = Label(digfilta, text="# Samples")
21295  bcasklab.grid(row=6, column=2, sticky=W)
21296  #
21297  #dismissdfbutton = Button(digfilta, text="Dismiss", style="W8.TButton", command=DestroyDigFiltScreen)
21298  #dismissdfbutton.grid(row=7, column=0, columnspan=1, sticky=W)
21299  #
21300  digfiltb = Frame( frame3 )
21301  digfiltb.pack(side=RIGHT)
21302  lab2 = Checkbutton(digfiltb,text="Filter CH B", variable=DigFiltB)
21303  lab2.grid(row=0, column=0, columnspan=2, sticky=W)
21304  lab4 = Checkbutton(digfiltb,text="Box Car", variable=DigFiltBBoxCar, command=BuildBoxCarB)
21305  lab4.grid(row=1, column=0, sticky=W)
21306  BCBLenEntry = Entry(digfiltb, width=3, cursor='double_arrow')
21307  BCBLenEntry.bind("<Return>", onRetDigFiltB)
21308  BCBLenEntry.bind('<MouseWheel>', onDigFiltBScroll)
21309  BCBLenEntry.bind("<Button-4>", onDigFiltBScroll)# with Linux OS
21310  BCBLenEntry.bind("<Button-5>", onDigFiltBScroll)
21311  # BCALenEntry.bind('<Key>', onTextKey)
21312  BCBLenEntry.grid(row=1, column=1, sticky=W)
21313  BCBLenEntry.delete(0,"end")
21314  BCBLenEntry.insert(0,2)
21315  bcblab = Label(digfiltb, text="Length")
21316  bcblab.grid(row=1, column=2, sticky=W)
21317  DifFiltBLength = Label(digfiltb,text="Length = 0 ")
21318  DifFiltBLength.grid(row=2, column=0, sticky=W)
21319  DifFiltBFile = Label(digfiltb,text="File Name, none ")
21320  DifFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
21321  cbld = Button(digfiltb, text='Load CH B Filter Coef', command=BLoadDFiltB)
21322  cbld.grid(row=4, column=0, columnspan=3, sticky=W)
21323  cbmath = Button(digfiltb, text='CH B Filter formula', command=BDFiltBMath)
21324  cbmath.grid(row=5, column=0, columnspan=3, sticky=W)
21325  # Deskew controls
21326  lab6 = Checkbutton(digfiltb,text="DeSkew B", variable=DigDeSkewB)# , command=BuildBoxCarA)
21327  lab6.grid(row=6, column=0, sticky=W)
21328  BCBSkewEntry = Entry(digfiltb, width=3, cursor='double_arrow')
21329  BCBSkewEntry.bind('<MouseWheel>', onTextScroll)
21330  BCBSkewEntry.bind("<Button-4>", onTextScroll)# with Linux OS
21331  BCBSkewEntry.bind("<Button-5>", onTextScroll)
21332  BCBSkewEntry.grid(row=6, column=1, sticky=W)
21333  BCBSkewEntry.delete(0,"end")
21334  BCBSkewEntry.insert(0,0)
21335  bcbsklab = Label(digfiltb, text="# Samples")
21336  bcbsklab.grid(row=6, column=2, sticky=W)
21337  # AWG A controls
21338  awgfilta = Frame( frame4 )
21339  awgfilta.pack(side=LEFT)
21340  lab7 = Checkbutton(awgfilta,text="Filter AWG A", variable=AWGFiltA, command=ReMakeAWGwaves)
21341  lab7.grid(row=0, column=0, columnspan=2, sticky=W)
21342  lab8 = Checkbutton(awgfilta,text="Box Car", variable=AWGFiltABoxCar, command=BuildAWGBoxCarA)
21343  lab8.grid(row=1, column=0, sticky=W)
21344  AWGALenEntry = Entry(awgfilta, width=3, cursor='double_arrow')
21345  AWGALenEntry.bind("<Return>", onRetAWGFiltA)
21346  AWGALenEntry.bind('<MouseWheel>', onAWGFiltAScroll)
21347  AWGALenEntry.bind("<Button-4>", onAWGFiltAScroll)# with Linux OS
21348  AWGALenEntry.bind("<Button-5>", onAWGFiltAScroll)
21349  # BCALenEntry.bind('<Key>', onTextKey)
21350  AWGALenEntry.grid(row=1, column=1, sticky=W)
21351  AWGALenEntry.delete(0,"end")
21352  AWGALenEntry.insert(0,2)
21353  awgalab = Label(awgfilta, text="Length")
21354  awgalab.grid(row=1, column=2, sticky=W)
21355  AWGFiltALength = Label(awgfilta, text="Length = 0 ")
21356  AWGFiltALength.grid(row=2, column=0, sticky=W)
21357  AWGFiltAFile = Label(awgfilta, text="File Name, none ")
21358  AWGFiltAFile.grid(row=3, column=0, columnspan=3, sticky=W)
21359  awgaload = Button(awgfilta, text='Load AWG A Filter Coef', command=BLoadAWGFiltA)
21360  awgaload.grid(row=4, column=0, columnspan=3, sticky=W)
21361  awgamath = Button(awgfilta, text='AWG A Filter formula', command=BAWGFiltAMath)
21362  awgamath.grid(row=5, column=0, columnspan=3, sticky=W)
21363  #
21364  # AWG B controls
21365  awgfiltb = Frame( frame5 )
21366  awgfiltb.pack(side=RIGHT)
21367  lab9 = Checkbutton(awgfiltb,text="Filter AWG B", variable=AWGFiltB, command=ReMakeAWGwaves)
21368  lab9.grid(row=0, column=0, columnspan=2, sticky=W)
21369  lab10 = Checkbutton(awgfiltb,text="Box Car", variable=AWGFiltBBoxCar, command=BuildAWGBoxCarB)
21370  lab10.grid(row=1, column=0, sticky=W)
21371  AWGBLenEntry = Entry(awgfiltb, width=3, cursor='double_arrow')
21372  AWGBLenEntry.bind("<Return>", onRetAWGFiltB)
21373  AWGBLenEntry.bind('<MouseWheel>', onAWGFiltBScroll)
21374  AWGBLenEntry.bind("<Button-4>", onAWGFiltBScroll)# with Linux OS
21375  AWGBLenEntry.bind("<Button-5>", onAWGFiltBScroll)
21376  # BCALenEntry.bind('<Key>', onTextKey)
21377  AWGBLenEntry.grid(row=1, column=1, sticky=W)
21378  AWGBLenEntry.delete(0,"end")
21379  AWGBLenEntry.insert(0,2)
21380  awgblab = Label(awgfiltb, text="Length")
21381  awgblab.grid(row=1, column=2, sticky=W)
21382  AWGFiltBLength = Label(awgfiltb, text="Length = 0 ")
21383  AWGFiltBLength.grid(row=2, column=0, sticky=W)
21384  AWGFiltBFile = Label(awgfiltb, text="File Name, none ")
21385  AWGFiltBFile.grid(row=3, column=0, columnspan=3, sticky=W)
21386  awgbload = Button(awgfiltb, text='Load AWG B Filter Coef', command=BLoadAWGFiltB)
21387  awgbload.grid(row=4, column=0, columnspan=3, sticky=W)
21388  awgbmath = Button(awgfiltb, text='AWG B Filter formula', command=BAWGFiltBMath)
21389  awgbmath.grid(row=5, column=0, columnspan=3, sticky=W)
21390  #
21391 def onRetDigFiltA(event):
21392  BuildBoxCarA()
21393 
21394 def onDigFiltAScroll(event):
21395  onTextScroll(event)
21396  BuildBoxCarA()
21397 
21399  global BCALenEntry, DFiltACoef, DigFiltABoxCar, DifFiltALength
21400 
21401  if DigFiltABoxCar.get() == 0:
21402  return
21403 
21404  FLength = int(BCALenEntry.get())
21405  if FLength < 2:
21406  return
21407 
21408  DFiltACoef = [] # empty coef array
21409 
21410  for n in range(FLength):
21411  DFiltACoef.append(float(1.0/FLength))
21412 
21413  DFiltACoef = numpy.array(DFiltACoef)
21414  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21415 
21416 def onRetDigFiltB(event):
21417  BuildBoxCarB()
21418 
21419 def onDigFiltBScroll(event):
21420  onTextScroll(event)
21421  BuildBoxCarB()
21422 
21424  global BCBLenEntry, DFiltBCoef, DigFiltBBoxCar, DifFiltBLength
21425 
21426  if DigFiltBBoxCar.get() == 0:
21427  return
21428 
21429  FLength = int(BCBLenEntry.get())
21430  if FLength < 2:
21431  return
21432 
21433  DFiltBCoef = [] # empty coef array
21434 
21435  for n in range(FLength):
21436  DFiltBCoef.append(float(1.0/FLength))
21437 
21438  DFiltBCoef = numpy.array(DFiltBCoef)
21439  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21440 
21442  global digfltwindow, DigFiltStatus
21443 
21444  DigFiltStatus.set(0)
21445  digfltwindow.destroy()
21446 
21448  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile
21449 
21450 # Read values from CVS file
21451  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21452  try:
21453  CSVFile = open(filename)
21454  csv_f = csv.reader(CSVFile)
21455  except:
21456  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21457  return
21458  DFiltACoef = []
21459 
21460  for row in csv_f:
21461  try:
21462  DFiltACoef.append(float(row[0]))
21463  except:
21464  print( 'skipping non-numeric row')
21465  DFiltACoef = numpy.array(DFiltACoef)
21466  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21467  DifFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21468  CSVFile.close()
21469 #
21471  global DFiltACoef, digfltwindow, DifFiltALength, DifFiltAFile, DigFilterAString
21472 
21473  TempString = DigFilterAString
21474  DigFilterAString = askstring("CH A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=DigFilterAString, parent=digfltwindow)
21475  if (DigFilterAString == None): # If Cancel pressed, then None
21476  DigFilterAString = TempString
21477  return
21478  DFiltACoef = eval(DigFilterAString)
21479  DFiltACoef = numpy.array(DFiltACoef)
21480  coefsum = numpy.sum(DFiltACoef)
21481  DFiltACoef = DFiltACoef / coefsum # always normalize to a gain of one
21482  DifFiltALength.config(text = "Length = " + str(int(len(DFiltACoef)))) # change displayed length value
21483  DifFiltAFile.config(text = "Using Filter A formula" ) # change displayed file name
21484 
21486  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile
21487 
21488 # Read values from CVS file
21489  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21490  try:
21491  CSVFile = open(filename)
21492  csv_f = csv.reader(CSVFile)
21493  except:
21494  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21495  return
21496  DFiltBCoef = []
21497 
21498  for row in csv_f:
21499  try:
21500  DFiltBCoef.append(float(row[0]))
21501  except:
21502  print( 'skipping non-numeric row')
21503  DFiltBCoef = numpy.array(DFiltBCoef)
21504  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21505  DifFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21506  CSVFile.close()
21507 #
21509  global DFiltBCoef, digfltwindow, DifFiltBLength, DifFiltBFile, DigFilterBString
21510 
21511  TempString = DigFilterBString
21512  DigFilterBString = askstring("CH B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=DigFilterBString, parent=digfltwindow)
21513  if (DigFilterBString == None): # If Cancel pressed, then None
21514  DigFilterBString = TempString
21515  return
21516  DFiltBCoef = eval(DigFilterBString)
21517  DFiltBCoef = numpy.array(DFiltBCoef)
21518  coefsum = numpy.sum(DFiltBCoef)
21519  DFiltBCoef = DFiltBCoef / coefsum
21520  DifFiltBLength.config(text = "Length = " + str(int(len(DFiltBCoef)))) # change displayed length value
21521  DifFiltBFile.config(text = "Using Filter B formula" ) # change displayed file name
21522 #
21523 def onRetAWGFiltA(event):
21524  BuildAWGBoxCarA()
21525 
21526 def onAWGFiltAScroll(event):
21527  onTextScroll(event)
21528  BuildAWGBoxCarA()
21529 
21531  global AWGALenEntry, AWGFiltACoef, AWGFiltABoxCar, AWGFiltALength
21532 
21533  if AWGFiltABoxCar.get() == 0:
21534  return
21535 
21536  FLength = int(AWGALenEntry.get())
21537  if FLength < 2:
21538  return
21539 
21540  AWGFiltACoef = [] # empty coef array
21541 
21542  for n in range(FLength):
21543  AWGFiltACoef.append(float(1.0/FLength))
21544 
21545  AWGFiltACoef = numpy.array(AWGFiltACoef)
21546  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21547  ReMakeAWGwaves()
21548 #
21549 def onRetAWGFiltB(event):
21550  BuildAWGBoxCarb()
21551 
21552 def onAWGFiltBScroll(event):
21553  onTextScroll(event)
21554  BuildAWGBoxCarB()
21555 
21557  global AWGBLenEntry, AWGFiltBCoef, AWGFiltBBoxCar, AWGFiltBLength
21558 
21559  if AWGFiltBBoxCar.get() == 0:
21560  return
21561 
21562  FLength = int(AWGBLenEntry.get())
21563  if FLength < 2:
21564  return
21565 
21566  AWGFiltBCoef = [] # empty coef array
21567 
21568  for n in range(FLength):
21569  AWGFiltBCoef.append(float(1.0/FLength))
21570 
21571  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21572  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21573  ReMakeAWGwaves()
21574 #
21576  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile
21577 
21578 # Read values from CVS file
21579  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21580  try:
21581  CSVFile = open(filename)
21582  csv_f = csv.reader(CSVFile)
21583  except:
21584  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21585  return
21586  AWGFiltACoef = []
21587 
21588  for row in csv_f:
21589  try:
21590  AWGFiltACoef.append(float(row[0]))
21591  except:
21592  print( 'skipping non-numeric row')
21593  AWGFiltACoef = numpy.array(AWGFiltACoef)
21594  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21595  AWGFiltAFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21596  CSVFile.close()
21597  ReMakeAWGwaves()
21598 #
21600  global AWGFiltACoef, digfltwindow, AWGFiltALength, AWGFiltAFile, AWGFilterAString
21601 
21602  TempString = AWGFilterAString
21603  AWGFilterAString = askstring("AWG A Filter Math Formula", "Current Formula: " + DigFilterAString + "\n\nNew Formula:\n", initialvalue=AWGFilterAString, parent=digfltwindow)
21604  if (AWGFilterAString == None): # If Cancel pressed, then None
21605  AWGFilterAString = TempString
21606  return
21607  AWGFiltACoef = eval(AWGFilterAString)
21608  AWGFiltACoef = numpy.array(AWGFiltACoef)
21609  coefsum = numpy.sum(AWGFiltACoef)
21610  AWGFiltACoef = AWGFiltACoef / coefsum
21611  AWGFiltALength.config(text = "Length = " + str(int(len(AWGFiltACoef)))) # change displayed length value
21612  AWGFiltAFile.config(text = "AWG A Filter formula" ) # change displayed file name
21613  ReMakeAWGwaves()
21614 #
21615 #
21617  global AWGFiltBCoef, digfltwindow, AWGFiltbLength, AWGFiltBFile
21618 
21619 # Read values from CVS file
21620  filename = askopenfilename(defaultextension = ".csv", filetypes=[("CSV files", "*.csv")], parent=digfltwindow)
21621  try:
21622  CSVFile = open(filename)
21623  csv_f = csv.reader(CSVFile)
21624  except:
21625  showwarning("WARNING","No such file found or wrong format!", parent=digfltwindow)
21626  return
21627  AWGFiltBCoef = []
21628 
21629  for row in csv_f:
21630  try:
21631  AWGFiltBCoef.append(float(row[0]))
21632  except:
21633  print( 'skipping non-numeric row')
21634  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21635  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21636  AWGFiltBFile.config(text = "File Name, " + os.path.basename(filename)) # change displayed file name
21637  CSVFile.close()
21638  ReMakeAWGwaves()
21639 #
21641  global AWGFiltBCoef, digfltwindow, AWGFiltBLength, AWGFiltBFile, AWGFilterBString
21642 
21643  TempString = AWGFilterBString
21644  AWGFilterBString = askstring("AWG B Filter Math Formula", "Current Formula: " + DigFilterBString + "\n\nNew Formula:\n", initialvalue=AWGFilterBString, parent=digfltwindow)
21645  if (AWGFilterBString == None): # If Cancel pressed, then None
21646  AWGFilterBString = TempString
21647  return
21648  AWGFiltBCoef = eval(AWGFilterBString)
21649  AWGFiltBCoef = numpy.array(AWGFiltBCoef)
21650  coefsum = numpy.sum(AWGFiltBCoef)
21651  AWGFiltBCoef = AWGFiltBCoef / coefsum
21652  AWGFiltBLength.config(text = "Length = " + str(int(len(AWGFiltBCoef)))) # change displayed length value
21653  AWGFiltBFile.config(text = "AWG B Filter formula" ) # change displayed file name
21654  ReMakeAWGwaves()
21655 #
21656 # Higher order SINC filters can be generated by convolving first order Box Car filters
21657 def BuildRejectFilter(Order, Freject, Fsample):
21658  # Order can be 1, 2, 3 or 4
21659  # Fsample = 100000
21660  # Calculate SINC1 oversample ratios for Freject
21661  osr = int(Fsample/Freject) #
21662  # osr60 = int(Fsample/60) # 60 Hz example
21663  # Create "boxcar" SINC1 filter
21664  sinc1 = numpy.ones(osr)
21665  # sinc1_60 = np.ones(osr60)
21666  # Calculate higher order filters
21667  sinc2 = numpy.convolve(sinc1, sinc1)
21668  sinc3 = numpy.convolve(sinc2, sinc1)
21669  sinc4 = numpy.convolve(sinc2, sinc2)
21670  fosr = float(Fsample/Freject)
21671  if Order == 1:
21672  return sinc1/fosr
21673  elif Order == 2:
21674  return sinc2/fosr
21675  elif Order == 3:
21676  return sinc3/fosr
21677  elif Order == 4:
21678  return sinc4/fosr
21679  else:
21680  return sinc1/fosr
21681  # Here's the SINC4-ish filter
21682  # with three zeros at 50Hz, one at 60Hz.
21683  # filt_50_60_rej = np.convolve(sinc3_50, sinc1_60)
21684 
21685 # Fit the function y = A * exp(B * x) to the data arrays xs and ys
21686 # returns (A, B)
21687 # From: https://mathworld.wolfram.com/LeastSquaresFittingExponential.html
21688 def fit_exp(xs, ys):
21689  S_x2_y = 0.0
21690  S_y_lny = 0.0
21691  S_x_y = 0.0
21692  S_x_y_lny = 0.0
21693  S_y = 0.0
21694  for (x,y) in zip(xs, ys):
21695  S_x2_y += x * x * y
21696  S_y_lny += y * numpy.log(y)
21697  S_x_y += x * y
21698  S_x_y_lny += x * y * numpy.log(y)
21699  S_y += y
21700  #end
21701  a = (S_x2_y * S_y_lny - S_x_y * S_x_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
21702  b = (S_y * S_x_y_lny - S_x_y * S_y_lny) / (S_y * S_x2_y - S_x_y * S_x_y)
21703  return (numpy.exp(a), b)
21704 #
21706  global commandwindow, CommandStatus, ExecString, LastCommand, RevDate, SWRev
21707 
21708  if CommandStatus.get() == 0:
21709  CommandStatus.set(1)
21710  commandwindow = Toplevel()
21711  commandwindow.title("Command Line " + SWRev + RevDate)
21712  commandwindow.resizable(FALSE,FALSE)
21713  commandwindow.protocol("WM_DELETE_WINDOW", DestroyCommandScreen)
21714  toplab = Label(commandwindow,text="Command Line Interface ", style="A12B.TLabel")
21715  toplab.grid(row=0, column=0, columnspan=4, sticky=W)
21716  cl1 = Label(commandwindow,text="Last command:")
21717  cl1.grid(row=1, column=0, sticky=W)
21718  LastCommand = Label(commandwindow,text=" ")
21719  LastCommand.grid(row=2, column=0, columnspan=4, sticky=W)
21720  ExecString = Entry(commandwindow, width=40)
21721  ExecString.bind("<Return>", RExecuteFromString)
21722  ExecString.grid(row=3, column=0, columnspan=4, sticky=W)
21723  ExecString.delete(0,"end")
21724  ExecString.insert(0,"")
21725  executeclbutton = Button(commandwindow, text="Execute", style="W8.TButton", command=BExecuteFromString)
21726  executeclbutton.grid(row=4, column=0, sticky=W, pady=8)
21727  scriptbutton = Button(commandwindow, text="Run Script", style="W10.TButton", command=RunScript)
21728  scriptbutton.grid(row=4, column=1, sticky=W, pady=8)
21729  #
21730  dismissclbutton = Button(commandwindow, text="Dismiss", style="W8.TButton", command=DestroyCommandScreen)
21731  dismissclbutton.grid(row=4, column=2, sticky=W, pady=7)
21732 
21734  global commandwindow, CommandStatus
21735 
21736  CommandStatus.set(0)
21737  commandwindow.destroy()
21738 
21740 
21742 
21743 def BExecuteFromString(): # global VBuffA,AWGAwaveform;VBuffA=AWGAwaveform
21744  global ExecString, LastCommand
21745  global VBuffA, VBuffB, IBuffA, IBuffB, VFilterA, VFilterB
21746  global VmemoryA, VmemoryB, ImemoryA, ImemoryB, AWGAwaveform, AWGBwaveform
21747  global TgInput, TgEdge, SingleShot, AutoLevel, SingleShotSA, ManualTrigger
21748  global root, freqwindow, awgwindow, iawindow, xywindow, win1, win2
21749  global TRIGGERentry, TMsb, Xsignal, Ysignal, AutoCenterA, AutoCenterB
21750  global CHAsb, CHAIsb, CHBsb, CHBIsb, HScale, FreqTraceMode
21751  global CHAsbxy, CHAIsbxy, CHBsbxy, CHBIsbxy, HoldOffentry
21752  global CHAVPosEntryxy, CHBVPosEntryxy, CHAIPosEntryxy, CHBIPosEntryxy
21753  global ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I, MathTrace, MathXUnits, MathYUnits
21754  global CHAVPosEntry, CHAIPosEntry, CHBVPosEntry, CHBIPosEntry, HozPossentry
21755  global AWGAAmplEntry, AWGAOffsetEntry, AWGAFreqEntry, AWGADutyCycleEntry
21756  global AWGAPhaseEntry, AWGAShape, AWGATerm, AWGAMode, AWGARepeatFlag, AWGBRepeatFlag
21757  global AWGBAmplEntry, AWGBOffsetEntry, AWGBFreqEntry, AWGBDutyCycleEntry
21758  global AWGBPhaseEntry, AWGBShape, AWGBTerm, AWGBMode, AWGSync, AWGAIOMode, AWGBIOMode
21759  global CHAVGainEntry, CHBVGainEntry, CHAVOffsetEntry, CHBVOffsetEntry
21760  global MeasDCV1, MeasMinV1, MeasMaxV1, MeasMidV1, MeasPPV1, MeasDCI1, MeasMinI1
21761  global MeasMaxI1, MeasMidI1, MeasPPI1, MeasDCV2, MeasMinV2, MeasMaxV2, MeasMidV2
21762  global MeasPPV2, MeasDCI2, MeasMinI2, MeasMaxI2, MeasMidI2, MeasPPI2, MeasDiffAB, MeasDiffBA
21763  global MeasRMSV1, MeasRMSV2, MeasRMSI1, MeasRMSI2, MeasPhase, MeasDelay
21764  global MeasAHW, MeasALW, MeasADCy, MeasAPER, MeasAFREQ, IASource, DisplaySeries
21765  global MeasBHW, MeasBLW, MeasBDCy, MeasBPER, MeasBFREQ
21766  global CHAIGainEntry, CHBIGainEntry, CHAIOffsetEntry, CHBIOffsetEntry
21767  global ShowC1_VdB, ShowC1_P, ShowC2_VdB, ShowC2_P, CutDC, AWG_Amp_Mode
21768  global FFTwindow, DBdivindex, DBlevel, TRACEmodeTime, TRACEaverage, Vdiv
21769  global SMPfftpwrTwo, SMPfft, StartFreqEntry, StopFreqEntry, ZEROstuffing
21770  global TimeDisp, XYDisp, FreqDisp, IADisp, AWGAPhaseDelay, AWGBPhaseDelay
21771  global RsystemEntry, ResScale, GainCorEntry, PhaseCorEntry
21772  global MeasTopV1, MeasBaseV1, MeasTopV2, MeasBaseV2
21773  global Show_CBA, Show_CBB, Show_CBC, Show_CBD, MuxScreenStatus, MuxEnb
21774  global CHB_Asb, CHB_APosEntry, CHB_Bsb, CHB_BPosEntry, muxwindow, ChopMuxMode, ChopTrig, DualMuxMode
21775  global CHB_Csb, CHB_CPosEntry, CHB_Dsb, CHB_DPosEntry
21776  global MathString, MathXString, MathYString, UserAString, UserALabel, UserBString, UserBLabel
21777  global MathAxis, MathXAxis, MathYAxis, Show_MathX, Show_MathY, MathScreenStatus, MathWindow
21778  global AWGAMathString, AWGBMathString, FFTUserWindowString, DigFilterAString, DigFilterBString
21779  global GRWF, GRHF, GRWBP, GRHBP, GRWXY, GRHXY, GRWIA, GRHIA, MeasureStatus
21780  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
21781  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
21782  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
21783  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
21784  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2, CHAI_RC_HP, CHBI_RC_HP
21785  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, RelPhaseCenter, ImpedanceCenter
21786  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
21787  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
21788  global Show_Rseries, Show_Xseries, Show_Magnitude, Show_Angle
21789  global AWGABurstFlag, AWGACycles, AWGABurstDelay, AWGAwaveform, AWGAcsvFile, AWGBcsvFile
21790  global AWGBBurstFlag, AWGBCycles, AWGBBurstDelay, AWGBwaveform, AWGAwavFile, AWGBwavFile
21791  global SCLKPort, SDATAPort, SLATCHPort, EnableHSsampling, FminEntry, HtMulEntry
21792  global phawindow, PhAca, PhAScreenStatus, PhADisp
21793  global GRWPhA, X0LPhA, GRHPhA, Y0TPhA, EnableScopeOnly
21794  global VScale, IScale, RefphEntry, SMPfft, BoardStatus, boardwindow, BrdSel
21795  global vat_btn, vbt_btn, iat_btn, ibt_btn, vabt_btn, RollBt, Roll_Mode
21796  global ShowPB_A, ShowPB_B, ShowPB_C, ShowPB_D, ScreenWidth, ScreenHeight
21797  global TRACEwidth, ColorMode, ca, COLORcanvas, COLORtrace4, COLORtraceR4, COLORtext
21798  global AWGANoiseEntry, AWGBNoiseEntry, AWGAsbnoise, AWGBsbnoise
21799  global AWGFiltA, AWGALenEntry, AWGFiltABoxCar, AWGFiltALength, digfltwindow
21800  global AWGFiltB, AWGBLenEntry, AWGFiltBBoxCar, AWGFiltBLength
21801  global DFiltACoef, DFiltBCoef, AWGACoef, AWGBCoef
21802 
21803  try:
21804  exec( ExecString.get(), globals(), globals())
21805  # exec( ExecString.get() )
21806  LastCommand.config(text = ExecString.get() ) # change displayed last command
21807  except:
21808  LastCommand.config(text = "Syntax Error Encountered" ) # change displayed last command
21809  return()
21810 #
21811 def CAresize(event):
21812  global ca, GRW, XOL, GRH, Y0T, CANVASwidth, CANVASheight, FontSize
21813 
21814  XOL = FontSize * 7
21815  CANVASwidth = event.width - 4
21816  CANVASheight = event.height - 4
21817  GRW = CANVASwidth - (2 * X0L) # new grid width
21818  GRH = CANVASheight - (Y0T + (FontSize * 7)) # new grid height
21819  UpdateTimeAll()
21820 #
21822  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
21823  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
21824  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
21825  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
21826  global ChaMeasString1, ChaMeasString2, ChaMeasString3, ChaMeasString4, ChaMeasString5, ChaMeasString6
21827  global ChbMeasString1, ChbMeasString2, ChbMeasString3, ChbMeasString4, ChbMeasString5, ChbMeasString6
21828 
21829  ValueText = ' {0:.4f} '.format(eval(ChaMeasString1))
21830  ChaValue1.config(text = ValueText)
21831  ValueText = ' {0:.4f} '.format(eval(ChaMeasString2))
21832  ChaValue2.config(text = ValueText)
21833  ValueText = ' {0:.4f} '.format(eval(ChaMeasString3))
21834  ChaValue3.config(text = ValueText)
21835  ValueText = ' {0:.4f} '.format(eval(ChaMeasString4))
21836  ChaValue4.config(text = ValueText)
21837  ValueText = ' {0:.4f} '.format(eval(ChaMeasString5))
21838  ChaValue5.config(text = ValueText)
21839  ValueText = ' {0:.4f} '.format(eval(ChaMeasString6))
21840  ChaValue6.config(text = ValueText)
21841  ValueText = ' {0:.4f} '.format(eval(ChbMeasString1))
21842  ChbValue1.config(text = ValueText)
21843  ValueText = ' {0:.4f} '.format(eval(ChbMeasString2))
21844  ChbValue2.config(text = ValueText)
21845  ValueText = ' {0:.4f} '.format(eval(ChbMeasString3))
21846  ChbValue3.config(text = ValueText)
21847  ValueText = ' {0:.4f} '.format(eval(ChbMeasString4))
21848  ChbValue4.config(text = ValueText)
21849  ValueText = ' {0:.4f} '.format(eval(ChbMeasString5))
21850  ChbValue5.config(text = ValueText)
21851  ValueText = ' {0:.4f} '.format(eval(ChbMeasString6))
21852  ChbValue6.config(text = ValueText)
21853 #
21855  global measurewindow, MeasureStatus, RevDate, SWRev
21856  global ChaLab1, ChaLab12, ChaLab3, ChaLab4, ChaLab5, ChaLab6
21857  global ChaValue1, ChaValue2, ChaValue3, ChaValue4, ChaValue5, ChaValue6
21858  global ChbLab1, ChbLab12, ChbLab3, ChbLab4, ChbLab5, ChbLab6
21859  global ChbValue1, ChbValue2, ChbValue3, ChbValue4, ChbValue5, ChbValue6
21860  global ChaLableSrring1, ChaLableSrring2, ChaLableSrring3, ChaLableSrring4, ChaLableSrring5, ChaLableSrring6
21861  global ChbLableSrring1, ChbLableSrring2, ChbLableSrring3, ChbLableSrring4, ChbLableSrring5, ChbLableSrring6
21862 
21863  if MeasureStatus.get() == 0:
21864  MeasureStatus.set(1)
21865  measurewindow = Toplevel()
21866  measurewindow.title("Measurements " + SWRev + RevDate)
21867  measurewindow.resizable(FALSE,FALSE)
21868  measurewindow.protocol("WM_DELETE_WINDOW", DestroyMeasureScreen)
21869  toplab = Label(measurewindow,text="Measurements ", style="A12B.TLabel")
21870  toplab.grid(row=0, column=0, columnspan=2, sticky=W)
21871  ChaLab1 = Label(measurewindow,text=ChaLableSrring1, style="A10B.TLabel")
21872  ChaLab1.grid(row=1, column=0, columnspan=1, sticky=W)
21873  ChaValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21874  ChaValue1.grid(row=1, column=1, columnspan=1, sticky=W)
21875  ChaLab2 = Label(measurewindow,text=ChaLableSrring2, style="A10B.TLabel")
21876  ChaLab2.grid(row=1, column=2, columnspan=1, sticky=W)
21877  ChaValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21878  ChaValue2.grid(row=1, column=3, columnspan=1, sticky=W)
21879  ChaLab3 = Label(measurewindow,text=ChaLableSrring3, style="A10B.TLabel")
21880  ChaLab3.grid(row=2, column=0, columnspan=1, sticky=W)
21881  ChaValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21882  ChaValue3.grid(row=2, column=1, columnspan=1, sticky=W)
21883  ChaLab4 = Label(measurewindow,text=ChaLableSrring4, style="A10B.TLabel")
21884  ChaLab4.grid(row=2, column=2, columnspan=1, sticky=W)
21885  ChaValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21886  ChaValue4.grid(row=2, column=3, columnspan=1, sticky=W)
21887  ChaLab5 = Label(measurewindow,text=ChaLableSrring5, style="A10B.TLabel")
21888  ChaLab5.grid(row=3, column=0, columnspan=1, sticky=W)
21889  ChaValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21890  ChaValue5.grid(row=3, column=1, columnspan=1, sticky=W)
21891  ChaLab6 = Label(measurewindow,text=ChaLableSrring6, style="A10B.TLabel")
21892  ChaLab6.grid(row=3, column=2, columnspan=1, sticky=W)
21893  ChaValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21894  ChaValue6.grid(row=3, column=3, columnspan=1, sticky=W)
21895  #
21896  ChbLab1 = Label(measurewindow,text=ChbLableSrring1, style="A10B.TLabel")
21897  ChbLab1.grid(row=4, column=0, columnspan=1, sticky=W)
21898  ChbValue1 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21899  ChbValue1.grid(row=4, column=1, columnspan=1, sticky=W)
21900  ChbLab2 = Label(measurewindow,text=ChbLableSrring2, style="A10B.TLabel")
21901  ChbLab2.grid(row=4, column=2, columnspan=1, sticky=W)
21902  ChbValue2 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21903  ChbValue2.grid(row=4, column=3, columnspan=1, sticky=W)
21904  ChbLab3 = Label(measurewindow,text=ChbLableSrring3, style="A10B.TLabel")
21905  ChbLab3.grid(row=5, column=0, columnspan=1, sticky=W)
21906  ChbValue3 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21907  ChbValue3.grid(row=5, column=1, columnspan=1, sticky=W)
21908  ChbLab4 = Label(measurewindow,text=ChbLableSrring4, style="A10B.TLabel")
21909  ChbLab4.grid(row=5, column=2, columnspan=1, sticky=W)
21910  ChbValue4 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21911  ChbValue4.grid(row=5, column=3, columnspan=1, sticky=W)
21912  ChbLab5 = Label(measurewindow,text=ChbLableSrring5, style="A10B.TLabel")
21913  ChbLab5.grid(row=6, column=0, columnspan=1, sticky=W)
21914  ChbValue5 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21915  ChbValue5.grid(row=6, column=1, columnspan=1, sticky=W)
21916  ChbLab6 = Label(measurewindow,text=ChbLableSrring6, style="A10B.TLabel")
21917  ChbLab6.grid(row=6, column=2, columnspan=1, sticky=W)
21918  ChbValue6 = Label(measurewindow,text="0.0000", style="A10B.TLabel")
21919  ChbValue6.grid(row=6, column=3, columnspan=1, sticky=W)
21920 #
21922  global measurewindow, MeasureStatus
21923 
21924  MeasureStatus.set(0)
21925  measurewindow.destroy()
21926 #
21928  global boardwindow, BoardStatus, session, devx, dev0, dev1, dev2, MultipleBoards
21929  global RevDate, BrdSel, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
21930 
21931  if len(session.devices) > 1 and MultipleBoards.get() > 0: # make screen only if more than one board present
21932  if BoardStatus.get() == 0:
21933  BoardStatus.set(1)
21934  boardwindow = Toplevel()
21935  boardwindow.title("Select Board " + RevDate)
21936  boardwindow.resizable(FALSE,FALSE)
21937  boardwindow.protocol("WM_DELETE_WINDOW", DestroyBoardScreen)
21938  toplab = Label(boardwindow,text="- Select ALM1000 -", style="A12B.TLabel")
21939  toplab.pack(side=TOP)
21940  for idx, devx in enumerate(session.devices):
21941  BrdText = "Board # " + str(idx)
21942  if idx == 0:
21943  devx.set_led(0b010) # LED.green
21944  FWRevOne = float(devx.fwver)
21945  HWRevOne = devx.hwver
21946  dev0 = devx #session.devices[0]
21947  brd = Radiobutton(boardwindow, text=BrdText, style="Run.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
21948  elif idx == 1:
21949  devx.set_led(0b100) # LED.blue,
21950  FWRevTwo = float(devx.fwver)
21951  HWRevTwo = devx.hwver
21952  dev1 = devx #session.devices[1]
21953  brd = Radiobutton(boardwindow, text=BrdText, style="Stop.TRadiobutton", variable=BrdSel, value=idx, command=SelectBoard)
21954  elif idx == 2:
21955  devx.set_led(0b001) # LED.red,
21956  FWRevThree = float(devx.fwver)
21957  HWRevThree = devx.hwver
21958  dev2 = devx #session.devices[2]
21959  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
21960  else:
21961  dev3 = session.devices[3]
21962  brd = Radiobutton(boardwindow, text=BrdText, variable=BrdSel, value=idx, command=SelectBoard)
21963  brd.pack(side=TOP)
21964  else:
21965  devx = session.devices[0]
21966  # devx.ignore_dataflow = True
21967  devx.set_led(0b010) # if only one board set LED.green
21968  try:
21969  FWRevOne = float(devx.fwver)
21970  HWRevOne = devx.hwver
21971  except:
21972  FWRevOne = "Before 2.06"
21973  HWRevOne = "?"
21974  dev0 = session.devices[0]
21975 #
21977  global boardwindow, BoardStatus
21978 
21979  BoardStatus.set(0)
21980  boardwindow.destroy()
21981 #
21983  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples, AWGSAMPLErate
21984  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree, SAMPLErate, MultipleBoards
21985 
21986  if DevID == "No Device" or DevID == "m1k":
21987  #print("Request sample rate: " + str(SAMPLErate))
21988  session = Session(ignore_dataflow=True, sample_rate=SAMPLErate, queue_size=MaxSamples)
21989  # session.add_all()
21990  # SAMPLErate = 200000 #AWGSAMPLErate # Scope sample rate
21991  if not session.devices:
21992  print( 'No Device plugged IN!')
21993  DevID = "No Device"
21994  FWRevOne = 0.0
21995  HWRevOne = "?"
21996  bcon.configure(text="Recon", style="RConn.TButton")
21997  return
21998  session.configure(sample_rate=SAMPLErate)
21999  # print("Session sample rate: " + str(session.sample_rate))
22000  MakeBoardScreen()
22001  SelectBoard()
22002  bcon.configure(text="Conn", style="GConn.TButton")
22003  devx.set_adc_mux(0)
22004  devx.ctrl_transfer(0x40, 0x24, 0x0, 0, 0, 0, 100) # set to addr DAC A
22005  devx.ctrl_transfer(0x40, 0x25, 0x1, 0, 0, 0, 100) # set not addr DAC B
22006 
22010  session.start(0)
22011 #
22013  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, RUNstatus, FWRevOne, HWRevOne
22014  global PIO_0, PIO_1, PIO_2, PIO_3, PIO_4, PIO_5, PIO_6, PIO_7, cal, SAMPLErate, MaxSamples
22015  global IgnoreFirmwareCheck, SDATAPort, SCLKPort, SLATCHPort
22016 
22017  if RUNstatus.get() == 1:
22018  BStop()
22019  print( "STOP")
22020 
22021  if BrdSel.get() == 0:
22022  try:
22023  session.remove(dev1)
22024  print( "Removing dev1")
22025  except:
22026  print( "Skipping dev1")
22027  try:
22028  session.remove(dev2)
22029  print( "Removing dev2")
22030  except:
22031  print( "Skipping dev2")
22032  session.add(dev0)
22033  devx = dev0
22034  #session.add(devx)
22035  if BrdSel.get() == 1:
22036  try:
22037  session.remove(dev0)
22038  print( "Removing dev0")
22039  except:
22040  print( "Skipping dev0")
22041  try:
22042  session.remove(dev2)
22043  print( "Removing dev2")
22044  except:
22045  print( "Skipping dev2")
22046  session.add(dev1)
22047  devx = dev1
22048  #session.add(devx)
22049  DevID = devx.serial
22050  print( DevID)
22051  FWRevOne = float(devx.fwver)
22052  HWRevOne = str(devx.hwver)
22053  print( FWRevOne, HWRevOne)
22054  # print("Session sample rate: " + str(session.sample_rate))
22055 
22056  if IgnoreFirmwareCheck == 0:
22057  if FWRevOne < 2.17:
22058  showwarning("WARNING","This ALICE version Requires Firmware version > 2.16")
22059  UpdateFirmware()
22060  cal = devx.calibration
22061  CHA = devx.channels['A'] # Open CHA
22062  CHA.mode = Mode.HI_Z_SPLIT # Put CHA in Hi Z split mode
22063  CHB = devx.channels['B'] # Open CHB
22064  CHB.mode = Mode.HI_Z_SPLIT # Put CHB in Hi Z split mode
22065  #
22066  # if session.continuous == 0:
22067  #session.start(0)
22068 
22077  devx.set_adc_mux(0)
22078  if devx.hwver == "F":
22079  print( "Rev F Board I/O ports set")
22080  PIO_0 = 28
22081  PIO_1 = 29
22082  PIO_2 = 47
22083  PIO_3 = 3
22084  PIO_4 = 4
22085  PIO_5 = 5
22086  PIO_6 = 6
22087  PIO_7 = 7
22088  else:
22089  PIO_0 = 0
22090  PIO_1 = 1
22091  PIO_2 = 2
22092  PIO_3 = 3
22093  PIO_4 = 4
22094  PIO_5 = 5
22095  PIO_6 = 6
22096  PIO_7 = 7
22097 #
22098  SDATAPort.set(PIO_1)
22099  SCLKPort.set(PIO_2)
22100  SLATCHPort.set(PIO_0)
22101 
22103  global SAMPLErate, AWGSAMPLErate, BaseSampleRate, session, ETSStatus, etssrlab, RevDate
22104  global Two_X_Sample, ADC_Mux_Mode, SampleRatewindow, SampleRateStatus, BaseRatesb
22105  global Alternate_Sweep_Mode, DeBugMode, FWRevOne, SWRev, SampRateList
22106  global FrameRefief, BorderSize
22107 
22108  if SampleRateStatus.get() == 0:
22109  SampleRateStatus.set(1)
22110  SampleRatewindow = Toplevel()
22111  SampleRatewindow.title("Set Sample Rate " + SWRev + RevDate)
22112  SampleRatewindow.resizable(FALSE,FALSE)
22113  SampleRatewindow.protocol("WM_DELETE_WINDOW", DestroySampleRate)
22114  frame1 = Frame(SampleRatewindow, borderwidth=BorderSize, relief=FrameRefief)
22115  frame1.grid(row=0, column=0, sticky=W)
22116  #
22117  BaseRATE = Frame( frame1 )
22118  BaseRATE.grid(row=0, column=0, sticky=W)
22119  baseratelab = Label(BaseRATE, text="Base Sample Rate", style="A10B.TLabel") #, font = "Arial 10 bold")
22120  baseratelab.pack(side=LEFT)
22121  BaseRatesb = Spinbox(BaseRATE, width=6, values=SampRateList, command=SetSampleRate)
22122  BaseRatesb.bind('<MouseWheel>', onSrateScroll)
22123  BaseRatesb.bind("<Button-4>", onSrateScroll)# with Linux OS
22124  BaseRatesb.bind("<Button-5>", onSrateScroll)
22125  BaseRatesb.bind("<Return>", onRetSrate)
22126  BaseRatesb.pack(side=LEFT)
22127  BaseRatesb.delete(0,"end")
22128  BaseRatesb.insert(0,BaseSampleRate)
22129  #
22130  nextrow = 2
22131  if FWRevOne > 2.16:
22132  twoX = Checkbutton(frame1, text="Double Sample Rate", variable=Two_X_Sample, command=SetADC_Mux )
22133  twoX.grid(row=1, column=0, sticky=W)
22134  muxlab1 = Label(frame1, text="ADC MUX Modes", style="A10B.TLabel") #, font = "Arial 10 bold")
22135  muxlab1.grid(row=2, column=0, sticky=W)
22136  AltSweep = Checkbutton(frame1, text="Alternate Sweep Mode", variable=Alternate_Sweep_Mode ) #, command=SetADC_Mux )
22137  AltSweep.grid(row=3, column=0, sticky=W)
22138  chabuttons = Frame( frame1 )
22139  chabuttons.grid(row=4, column=0, sticky=W)
22140  muxrb1 = Radiobutton(chabuttons, text="VA and VB", variable=ADC_Mux_Mode, value=0, command=SetADC_Mux ) #style="W8.TButton",
22141  muxrb1.pack(side=LEFT)
22142  muxrb2 = Radiobutton(chabuttons, text="IA and IB", variable=ADC_Mux_Mode, value=1, command=SetADC_Mux ) #style="W8.TButton",
22143  muxrb2.pack(side=LEFT)
22144  chcbuttons = Frame( frame1 )
22145  chcbuttons.grid(row=5, column=0, sticky=W)
22146  muxrb5 = Radiobutton(chcbuttons, text="VA and IA", variable=ADC_Mux_Mode, value=4, command=SetADC_Mux ) # style="W8.TButton",
22147  muxrb5.pack(side=LEFT)
22148  muxrb6 = Radiobutton(chcbuttons, text="VB and IB", variable=ADC_Mux_Mode, value=5, command=SetADC_Mux ) # style="W8.TButton",
22149  muxrb6.pack(side=LEFT)
22150  nextrow = 6
22151  if DeBugMode == 1:
22152  chbbuttons = Frame( frame1 )
22153  chbbuttons.grid(row=nextrow, column=0, sticky=W)
22154  muxrb3 = Radiobutton(chbbuttons, text="VA and IB", variable=ADC_Mux_Mode, value=2, command=SetADC_Mux ) # style="W8.TButton",
22155  muxrb3.pack(side=LEFT)
22156  muxrb4 = Radiobutton(chbbuttons, text="VB and IA", variable=ADC_Mux_Mode, value=3, command=SetADC_Mux ) # style="W8.TButton",
22157  muxrb4.pack(side=LEFT)
22158  nextrow = nextrow + 1
22159  #
22160  sratedismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroySampleRate)
22161  sratedismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
22162 #
22164  global SampleRatewindow, SampleRateStatus
22165 
22166  SampleRateStatus.set(0)
22167  SampleRatewindow.destroy()
22168 #
22169 #
22170 def onSrateScroll(event):
22171 
22172  #onTextScroll
22173  onSpinBoxScroll(event)
22174  SetSampleRate()
22175 #
22176 def onRetSrate(event):
22177 
22178  SetSampleRate()
22179 #
22181  global SAMPLErate, BaseSampleRate, AWGSAMPLErate, session, ETSStatus, etssrlab, BaseRatesb
22182  global Two_X_Sample, ADC_Mux_Mode, rtsrlab, RUNstatus
22183 
22184  #
22185  WasRunning = 0
22186  if (RUNstatus.get() == 1):
22187  WasRunning = 1
22188  BStop() # Force Stop loop if running
22189  try:
22190  NewRate = int(BaseRatesb.get())
22191  if NewRate <= 100000: # rate has to be less than or equal to 100,000
22192  BaseSampleRate = NewRate
22193  else:
22194  BaseSampleRate = 100000
22195  BaseRatesb.delete(0,"end")
22196  BaseRatesb.insert(0,BaseSampleRate)
22197  SAMPLErate = BaseSampleRate # Scope sample rate
22198  except:
22199  donothing()
22200  session.configure(sample_rate=BaseSampleRate)
22201  BaseSampleRate = session.sample_rate
22202  #print("Session sample rate: " + str(session.sample_rate), BaseSampleRate)
22203  SAMPLErate = BaseSampleRate # Scope sample rate
22204  #print("Session sample rate: " + str(session.sample_rate), SAMPLErate)
22205  AWGSAMPLErate = BaseSampleRate
22206  if ETSStatus.get() > 0:
22207  SRstring = "RT Sample Rate = " + str(BaseSampleRate)
22208  rtsrlab.config(text=SRstring)
22209  ETSUpdate()
22210  BaseRatesb.delete(0,"end")
22211  BaseRatesb.insert(0,BaseSampleRate)
22212  ReMakeAWGwaves() # remake AWG waveforms for new rate
22213  if (WasRunning == 1):
22214  WasRunning = 0
22215  BStart() # restart loop if was running
22216 #
22217 def onStopfreqScroll(event):
22218  global StopFreqEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
22219 
22220  onTextScroll(event)
22221  try:
22222  StopFrequency = float(StopFreqEntry.get())
22223  except:
22224  StopFreqEntry.delete(0,"end")
22225  StopFreqEntry.insert(0,50000)
22226  StopFrequency = 50000
22227  if FWRevOne > 2.16:
22228  if StopFrequency >= 50000:
22229  Two_X_Sample.set(1)
22230  ADC_Mux_Mode.set(0)
22231  SetADC_Mux()
22232  else:
22233  Two_X_Sample.set(0)
22234  ADC_Mux_Mode.set(0)
22235  SetADC_Mux()
22236 #
22237 def onStopBodeScroll(event):
22238  global StopBodeEntry, Two_X_Sample, ADC_Mux_Mode, FWRevOne
22239 
22240  onTextScroll(event)
22241  try:
22242  StopFrequency = float(StopBodeEntry.get())
22243  except:
22244  StopBodeEntry.delete(0,"end")
22245  StopBodeEntry.insert(0,20000)
22246  StopFrequency = 20000
22247  if FWRevOne > 2.16:
22248  if StopFrequency >= 20000:
22249  Two_X_Sample.set(1)
22250  ADC_Mux_Mode.set(0)
22251  SetADC_Mux()
22252  else:
22253  Two_X_Sample.set(0)
22254  ADC_Mux_Mode.set(0)
22255  SetADC_Mux()
22256 #
22258  global devx, SAMPLErate, BaseSampleRate, Two_X_Sample, ADC_Mux_Mode, CHA, CHB
22259  global v1_adc_conf, i1_adc_conf, v2_adc_conf, i2_adc_conf
22260  global AWGSync, discontloop, session, ADsignal1
22261 
22262  if Two_X_Sample.get() == 1:
22263  if ADC_Mux_Mode.get() == 0: # VA and VB
22264  devx.set_adc_mux(1)
22265  elif ADC_Mux_Mode.get() == 1: # IA and IB
22266  devx.set_adc_mux(2)
22267  elif ADC_Mux_Mode.get() == 2: # VA and IB
22268  # cycle trhough default mux values as starting point
22269  devx.set_adc_mux(2)
22270  # now set new mux values
22271  devx.set_adc_mux(7)
22272  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
22273  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
22274  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
22275  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
22276  time.sleep(0.1)
22277  elif ADC_Mux_Mode.get() == 3: # VB and IA
22278  # cycle trhough default mux values as starting point
22279  # now set new mux values
22280  devx.set_adc_mux(7)
22281  devx.ctrl_transfer(0x40, 0x20, v1_adc_conf, 0, 0, 0, 100) # U12
22282  devx.ctrl_transfer(0x40, 0x21, i1_adc_conf, 0, 0, 0, 100) # U12
22283  devx.ctrl_transfer(0x40, 0x22, v2_adc_conf, 0, 0, 0, 100) # U11
22284  devx.ctrl_transfer(0x40, 0x22, i2_adc_conf, 0, 0, 0, 100) # U11
22285  time.sleep(0.1)
22286  elif ADC_Mux_Mode.get() == 4: # VA and IA
22287  # cycle trhough default mux values as starting point
22288  devx.set_adc_mux(2)
22289  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
22290  if discontloop > 0:
22291  session.flush()
22292  else:
22293  discontloop = 1
22294  time.sleep(0.01)
22295  BAWGEnab()
22296  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
22297 
22298  else: # running in continuous mode
22299  if session.continuous:
22300  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
22301  # now set new mux values
22302  devx.set_adc_mux(4)
22303  elif ADC_Mux_Mode.get() == 5: # VB and IB
22304  # cycle trhough default mux values as starting point
22305  devx.set_adc_mux(2)
22306  if AWGSync.get() > 0: # awg syn flag set so run in discontinuous mode
22307  if discontloop > 0:
22308  session.flush()
22309  else:
22310  discontloop = 1
22311  time.sleep(0.01)
22312  BAWGEnab()
22313  ADsignal1 = devx.get_samples(1000) # get samples for both channel A and B
22314 
22315  else: # running in continuous mode
22316  if session.continuous:
22317  ADsignal1 = devx.read(1000, -1, True) # get samples for both channel A and B
22318  # now set new mux values
22319  devx.set_adc_mux(5)
22320  SAMPLErate = BaseSampleRate * 2 # set to 2X sample mode
22321  else:
22322  devx.set_adc_mux(0)
22323  SAMPLErate = BaseSampleRate
22324 #
22326  global ADC_Mux_Mode, Alternate_Sweep_Mode, ShowC1_V, ShowC1_I, ShowC2_V, ShowC2_I
22327 
22328  if ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22329  ADC_Mux_Mode.set(0) # All four traces
22330  Alternate_Sweep_Mode.set(1)
22331  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 0:
22332  ADC_Mux_Mode.set(0) # three traces
22333  Alternate_Sweep_Mode.set(1)
22334  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22335  ADC_Mux_Mode.set(0) # three traces
22336  Alternate_Sweep_Mode.set(1)
22337  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22338  ADC_Mux_Mode.set(0) # three traces
22339  Alternate_Sweep_Mode.set(1)
22340  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22341  ADC_Mux_Mode.set(0) # three traces
22342  Alternate_Sweep_Mode.set(1)
22343  #
22344  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22345  ADC_Mux_Mode.set(1) # IA and IB
22346  Alternate_Sweep_Mode.set(0)
22347  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
22348  ADC_Mux_Mode.set(1) # just IA
22349  Alternate_Sweep_Mode.set(0)
22350  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 0 and ShowC2_I.get() == 1:
22351  ADC_Mux_Mode.set(1) # just IB
22352  Alternate_Sweep_Mode.set(0)
22353  elif ShowC1_V.get() == 1 and ShowC1_I.get() == 1 and ShowC2_V.get() == 0 and ShowC2_I.get() == 0:
22354  ADC_Mux_Mode.set(4) # VA and IA
22355  Alternate_Sweep_Mode.set(0)
22356  elif ShowC1_V.get() == 0 and ShowC1_I.get() == 0 and ShowC2_V.get() == 1 and ShowC2_I.get() == 1:
22357  ADC_Mux_Mode.set(5) # VB and IB
22358  Alternate_Sweep_Mode.set(0)
22359  else:
22360  ADC_Mux_Mode.set(0)
22361  Alternate_Sweep_Mode.set(0)
22362  SetADC_Mux()
22363  UpdateTimeTrace()
22364 #
22366  global devx, dev0, dev1, dev2, session, BrdSel, CHA, CHB, DevID, MaxSamples
22367  global bcon, FWRevOne, HWRevOne, FWRevTwo, HWRevTwo, WRevThree, HWRevThree
22368 
22369  RUNstatus.set(0)
22370  if askyesno("Update current firmware","Flash new firmware to current device:\n(Yes) or (No)?"):
22371  filename = askopenfilename(defaultextension = ".bin", filetypes=[("Binary", "*.bin")])
22372  print( filename)
22373  #print DevID
22374  #print FWRevOne, HWRevOne # devx.fwver, devx.hwver
22375  try:
22376  print( "Cancel current session.")
22377  session.cancel()
22378  print( session.cancelled)
22379  session.end()
22380  print( "Waiting 5...")
22381  time.sleep(5)
22382  print( "Put board in Samba mode and flash firmware.")
22383  session.flash_firmware(filename)
22384  except:
22385  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
22386 
22394  showwarning("Complete","Flash Firmware Complete: \n Un-plug board to cycle power.")
22395  showwarning("Exit ALICE","Must Exit Program: \n Restart ALICE to continue.")
22396  Bcloseexit()
22397 
22407  global OhmDisp, OhmStatus, ohmwindow, RevDate, RMode, OhmA0, OhmA1, OhmRunStatus
22408  global CHATestVEntry, CHATestREntry, SWRev, AWGSync, OnBoardRes
22409  global FrameRefief, BorderSize
22410 
22411  if OhmStatus.get() == 0:
22412  AWGSync.set(1)
22413  OhmStatus.set(1)
22414  OhmDisp.set(1)
22415  OhmCheckBox()
22416  ohmwindow = Toplevel()
22417  ohmwindow.title("DC Ohmmeter " + SWRev + RevDate)
22418  ohmwindow.resizable(FALSE,FALSE)
22419  ohmwindow.protocol("WM_DELETE_WINDOW", DestroyOhmScreen)
22420  frame1 = Frame(ohmwindow, borderwidth=BorderSize, relief=FrameRefief)
22421  frame1.grid(row=0, column=0, sticky=W)
22422  #
22423  buttons = Frame( frame1 )
22424  buttons.grid(row=0, column=0, sticky=W)
22425  omrb2 = Radiobutton(buttons, text="Run", style="Run.TRadiobutton", variable=OhmRunStatus, value=1, command=BStartOhm )
22426  omrb2.pack(side=LEFT)
22427  omrb1 = Radiobutton(buttons, text="Stop", style="Stop.TRadiobutton", variable=OhmRunStatus, value=0, command=BStop )
22428  omrb1.pack(side=LEFT)
22429  #
22430  OhmA0 = Label(frame1, style="A16B.TLabel") # , font = "Arial 16 bold")
22431  OhmA0.grid(row=1, column=0, columnspan=2, sticky=W)
22432  OhmA0.config(text = "0.000 Ohms")
22433 
22434  OhmA1 = Label(frame1, style="A12B.TLabel") #, font = "Arial 12 bold")
22435  OhmA1.grid(row=2, column=0, columnspan=2, sticky=W)
22436  OhmA1.config(text = "Meas 0.00 mA 0.00 V")
22437  #
22438  TestVA = Frame( frame1 )
22439  TestVA.grid(row=3, column=0, sticky=W)
22440  chatestvlab = Label(TestVA, text="Test Voltage", style="A10B.TLabel") #, font = "Arial 10 bold")
22441  chatestvlab.pack(side=LEFT)
22442  CHATestVEntry = Entry(TestVA, width=6, cursor='double_arrow') #
22443  CHATestVEntry.pack(side=LEFT)
22444  CHATestVEntry.bind('<MouseWheel>', onTextScroll)
22445  CHATestVEntry.bind("<Button-4>", onTextScroll)# with Linux OS
22446  CHATestVEntry.bind("<Button-5>", onTextScroll)
22447  CHATestVEntry.delete(0,"end")
22448  CHATestVEntry.insert(0,5.0)
22449  #
22450  RMode = IntVar(0)
22451  RMode.set(1)
22452  TestMode = Frame( frame1 )
22453  TestMode.grid(row=4, column=0, sticky=W)
22454  modelab = Label(TestMode, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
22455  modelab.pack(side=LEFT)
22456  rm3 = Radiobutton(TestMode, text="Ext", variable=RMode, value=0)
22457  rm3.pack(side=LEFT)
22458  rm4 = Radiobutton(TestMode, text="Int", variable=RMode, value=1)
22459  rm4.pack(side=LEFT)
22460  #
22461  TestRA = Frame( frame1 )
22462  TestRA.grid(row=5, column=0, sticky=W)
22463  chatestrlab = Label(TestRA, text="Known Res", style="A10B.TLabel") #, font = "Arial 10 bold")
22464  chatestrlab.pack(side=LEFT)
22465  CHATestREntry = Entry(TestRA, width=6, cursor='double_arrow') #
22466  CHATestREntry.pack(side=LEFT)
22467  CHATestREntry.bind('<MouseWheel>', onTextScroll)
22468  CHATestREntry.bind("<Button-4>", onTextScroll)# with Linux OS
22469  CHATestREntry.bind("<Button-5>", onTextScroll)
22470  CHATestREntry.delete(0,"end")
22471  CHATestREntry.insert(0,OnBoardRes)
22472  #
22473  ohmdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOhmScreen)
22474  ohmdismissclbutton.grid(row=6, column=0, sticky=W, pady=7)
22475 #
22477  global ohmwindow, OhmStatus, OhmDisp
22478 
22479  OhmStatus.set(0)
22480  OhmDisp.set(0)
22481  OhmCheckBox()
22482  ohmwindow.destroy()
22483 #
22485  global FMulXEntry, MulXEntry, etswindow, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate
22486  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, enb1, rtsrlab, etssrlab, RevDate, SWRev
22487  global MinigenScreenStatus, DeBugMode
22488  global FrameRefief, BorderSize
22489 
22490  #
22491  if ETSStatus.get() == 0:
22492  BaseFreq = (-10, -15, -20, -25, -30, -35, -40, -45, -50, -60, -70, -80, -90, -100)
22493  ETSStatus.set(1)
22494  ETSDisp.set(0)
22495  etswindow = Toplevel()
22496  etswindow.title("ETS Controls " + SWRev + RevDate)
22497  etswindow.resizable(FALSE,FALSE)
22498  etswindow.protocol("WM_DELETE_WINDOW", DestroyETSScreen)
22499  frame1 = Frame(etswindow, borderwidth=BorderSize, relief=FrameRefief)
22500  frame1.grid(row=0, column=0, sticky=W)
22501  # Sampling controls Widgets
22502  SRstring = "RT Sample Rate = " + str(SAMPLErate)
22503  rtsrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
22504  rtsrlab.grid(row=1, column=0, sticky=W)
22505  ESRstring = "ET Sample Rate = " + str(SAMPLErate)
22506  etssrlab = Label(frame1, text=SRstring, style= "A10B.TLabel")
22507  etssrlab.grid(row=2, column=0, sticky=W)
22508  etssrbutton = Button(frame1, text="Set RT Sample Rate", command=MakeSampleRateMenu) #, style= "W8.TButton"
22509  etssrbutton.grid(row=3, column=0, sticky=W, pady=7)
22510  enb1 = Checkbutton(frame1,text="Enable ETS", variable=ETSDisp, command=ETSCheckBox)
22511  enb1.grid(row=4, column=0, sticky=W)
22512  #
22513  Divx = Frame( frame1 )
22514  Divx.grid(row=5, column=0, sticky=W)
22515  DivXEntry = Entry(Divx, width=6, cursor='double_arrow')
22516  DivXEntry.bind('<MouseWheel>', ETSscroll)
22517  DivXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
22518  DivXEntry.bind("<Button-5>", ETSscroll)
22519  DivXEntry.pack(side=RIGHT)
22520  DivXEntry.delete(0,"end")
22521  DivXEntry.insert(0,2)
22522  divxlab = Label( Divx, text = "Divide Factor")
22523  divxlab.pack(side=RIGHT)
22524  GridRow = 5
22525  #
22526  if DeBugMode > 0:
22527  FOffEntry = Label(frame1, text="Samples")
22528  FOffEntry.grid(row=GridRow+1, column=0, sticky=W)
22529  MulXEntry = Label( frame1, text = "Rec Len Mul")
22530  MulXEntry.grid(row=GridRow+2, column=0, sticky=W)
22531  GridRow = GridRow + 2
22532  #
22533  eqivsamplerate = Label(frame1, text="MHz", style= "A10B.TLabel")
22534  eqivsamplerate.grid(row=GridRow+1, column=0, sticky=W)
22535  #
22536  FConv = Frame( frame1 )
22537  FConv.grid(row=GridRow+2, column=0, sticky=W)
22538  FMulXEntry = Entry(FConv, width=3, cursor='double_arrow')
22539  FMulXEntry.bind('<MouseWheel>', ETSscroll)
22540  FMulXEntry.bind("<Button-4>", ETSscroll)# with Linux OS
22541  FMulXEntry.bind("<Button-5>", ETSscroll)
22542  FMulXEntry.pack(side=RIGHT)
22543  FMulXEntry.delete(0,"end")
22544  FMulXEntry.insert(0,1)
22545  fminlab = Label( FConv, text = "Freq Multiplier")
22546  fminlab.pack(side=RIGHT)
22547  #
22548  FminDisp = Label(frame1, text="32768 Hz", style= "A10B.TLabel")
22549  FminDisp.grid(row=GridRow+3, column=0, sticky=W)
22550  #
22551  if MinigenScreenStatus.get() > 0:
22552  mgloadbutton = Button(frame1, text="Load to MinGen", command=MGLoad)
22553  mgloadbutton.grid(row=GridRow+4, column=0, sticky=W)
22554  GridRow = GridRow + 1
22555  #
22556  dirlab = Label(frame1, text="Sample Data Order", style= "A10B.TLabel")
22557  dirlab.grid(row=GridRow+5, column=0, sticky=W)
22558  DataMode = Frame( frame1 )
22559  DataMode.grid(row=GridRow+6, column=0, sticky=W)
22560  dm3 = Radiobutton(DataMode, text="Forward", variable=ETSDir, value=0)
22561  dm3.pack(side=LEFT)
22562  dm4 = Radiobutton(DataMode, text="Reverse", variable=ETSDir, value=1)
22563  dm4.pack(side=LEFT)
22564  tclab = Label(frame1, text="CH B Time Shift", style= "A10B.TLabel")
22565  tclab.grid(row=GridRow+7, column=0, sticky=W)
22566  TSMode = Frame( frame1 )
22567  TSMode.grid(row=GridRow+8, column=0, sticky=W)
22568  ETSts = Entry(TSMode, width=6, cursor='double_arrow')
22569  ETSts.bind('<MouseWheel>', ETSscroll)
22570  ETSts.bind("<Button-4>", ETSscroll)# with Linux OS
22571  ETSts.bind("<Button-5>", ETSscroll)
22572  ETSts.pack(side=RIGHT)
22573  ETSts.delete(0,"end")
22574  ETSts.insert(0,1)
22575  ETStslab = Label( TSMode, text = "Factor")
22576  ETStslab.pack(side=RIGHT)
22577  #
22578  etsdismissclbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroyETSScreen)
22579  etsdismissclbutton.grid(row=GridRow+9, column=0, sticky=W, pady=7)
22580  ETSDisp.set(0)
22581  ETSCheckBox()
22582 #
22584  global etswindow, ETSStatus, ETSDisp
22585 
22586  ETSStatus.set(0)
22587  ETSDisp.set(0)
22588  ETSCheckBox()
22589  etswindow.destroy()
22590 #
22591 def MGLoad():
22592  global MinigenFout, Fmin, ETSDir
22593 
22594  MinigenFout.delete(0,"end")
22595  if ETSDir.get() == 0:
22596  MinigenFout.insert(0,Fmin+20)
22597  else:
22598  MinigenFout.insert(0,Fmin-20)
22599  BSendMG()
22600 #
22601 def ETSscroll(event):
22602  onTextScroll(event)
22603  ETSUpdate()
22604 #
22605 def onFminScroll(event):
22606  onTextScroll(event)
22607  ETSUpdate()
22608  SetETSComp()
22609  SetAD9833(event)
22610 
22611 def onMulXScroll(event):
22612  global Two_X_Sample, HtMulEntry, ETSts, etssrlab, SAMPLErate
22613 
22614  onTextScroll(event)
22615  # ETSUpdate()
22616  try:
22617  TscaleX = float(HtMulEntry.get())
22618  except:
22619  HtMulEntry.delete(0,END)
22620  HtMulEntry.insert(0, 1)
22621  if Two_X_Sample.get() == 0:
22622  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
22623  else:
22624  ToffsetX = 0
22625  ETSts.delete(0,"end")
22626  ETSts.insert(0,ToffsetX)
22627  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
22628  etssrlab.config(text=SRstring)
22629  #
22630  SetETSComp()
22631  SetAD9833(event)
22632 #
22634  global FMulXEntry, MulXEntry, ETSStatus, ETSDisp, ETSDir, ETSts, eqivsamplerate, MaxETSrecord
22635  global SAMPLErate, DivXEntry, FOffEntry, FminDisp, DivX, FOff, MulX, Fmin, FMul, SAMPLErate, TIMEdiv
22636  global FminEntry, HtMulEntry, Two_X_Sample, DeBugMode
22637 
22638  if TIMEdiv > 0.2:
22639  MaxETSrecord = int(SAMPLErate * 10 * TIMEdiv / 1000.0)
22640  else:
22641  MaxETSrecord = int(SAMPLErate * 20 * TIMEdiv / 1000.0)
22642  if (MaxETSrecord*100) > MaxSamples:
22643  MaxETSrecord = MaxSamples / 100
22644  try:
22645  DivX = float(eval(DivXEntry.get()))
22646  if DivX < 2:
22647  DivX = 2
22648  if DivX > 75:
22649  DivX = 75
22650  DivXEntry.delete(0,END)
22651  DivXEntry.insert(0, DivX)
22652  except:
22653  DivXEntry.delete(0,END)
22654  DivXEntry.insert(0, DivX)
22655  #
22656  FOff = 25
22657  MulX = (DivX*SAMPLErate)/(100*FOff)
22658  while MulX > MaxETSrecord:
22659  FOff = FOff + 5
22660  MulX = (DivX*SAMPLErate)/(100*FOff)
22661  FOff = 0 - FOff
22662  if DeBugMode > 0:
22663  SRstring = "Rec Len Mul = " + str(MulX) + " samples"
22664  MulXEntry.config(text = SRstring) # change displayed value
22665  SRstring = "Offset = " + str(FOff) + " samples"
22666  FOffEntry.config(text = SRstring) # change displayed value
22667  baseFreq = SAMPLErate/DivX
22668  try:
22669  FMul = float(eval(FMulXEntry.get()))
22670  if FMul < 1:
22671  FMul = 1
22672  FMulXEntry.delete(0,END)
22673  FMulXEntry.insert(0, int(FMul))
22674  if FMul > 75:
22675  FMul = 75
22676  FMulXEntry.delete(0,END)
22677  FMulXEntry.insert(0, int(FMul))
22678  except:
22679  FMulXEntry.delete(0,END)
22680  FMulXEntry.insert(0, int(FMul))
22681  FreqMin = baseFreq * FMul
22682  SRstring = "Multiplied Freq = " + ' {0:.1f} '.format(FreqMin) + " Hz"
22683  FminDisp.config(text = SRstring) # change displayed value
22684  SRstring = "Base Frequency = " + ' {0:.2f} '.format(baseFreq) + " Hz"
22685  eqivsamplerate.config(text = SRstring) # change displayed value
22686  # calculate time scale multiplication factor
22687  try:
22688  MinFreq = eval(FminEntry.get()) * 1000 # convert KHz to Hz
22689  except:
22690  FminEntry.delete(0,END)
22691  FminEntry.insert(0, 25)
22692  #
22693  try: # catch for divide by zero
22694  TscaleX = int((MinFreq)/(DivX * (MinFreq - FreqMin)))
22695  except:
22696  TscaleX = 1
22697 
22698  if TscaleX > 0:
22699  ETSDir.set(0) # set sample direction to forward if positive
22700  else:
22701  ETSDir.set(1) # set sample direction to reverse if negative
22702  TscaleX = abs(TscaleX)
22703  if Two_X_Sample.get() == 0:
22704  ToffsetX = TscaleX/10.0 # set channel B offset to 1/10 the time scale only for 1X sampeling
22705  else:
22706  ToffsetX = 0
22707  ETSts.delete(0,"end")
22708  ETSts.insert(0,ToffsetX)
22709 
22710  HtMulEntry.delete(0,END)
22711  HtMulEntry.insert(0, TscaleX)
22712  SRstring = "RT Sample Rate = " + str(SAMPLErate)
22713  rtsrlab.config(text=SRstring)
22714  SRstring = "ET Sample Rate = " + str(SAMPLErate*TscaleX)
22715  etssrlab.config(text=SRstring)
22716 #
22717 def Settingsscroll(event):
22718  onTextScroll(event)
22719  SettingsUpdate()
22720 #
22721 def SettingsTextKey(event):
22722  onTextKey(event)
22723  SettingsUpdate()
22724 #
22726  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
22727  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
22728  global AWG_Amp_Mode, SWRev, EnableHSsampling, Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
22729  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry, TrgLPFEntry, Trigger_LPF_length
22730  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
22731  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
22732  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
22733  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
22734  global FrameRefief, BorderSize
22735 
22736  if SettingsStatus.get() == 0:
22737  SettingsStatus.set(1)
22738  Settingswindow = Toplevel()
22739  Settingswindow.title("Settings " + SWRev + RevDate)
22740  Settingswindow.resizable(FALSE,FALSE)
22741  Settingswindow.protocol("WM_DELETE_WINDOW", DestroySettings)
22742  frame1 = Frame(Settingswindow, borderwidth=BorderSize, relief=FrameRefief)
22743  frame1.grid(row=0, column=0, sticky=W)
22744  #
22745  zstlab = Label(frame1, text="FFT Zero Stuffing", style= "A10B.TLabel")
22746  zstlab.grid(row=0, column=0, sticky=W)
22747  zstMode = Frame( frame1 )
22748  zstMode.grid(row=0, column=1, sticky=W)
22749  ZSTuff = Entry(zstMode, width=4, cursor='double_arrow')
22750  ZSTuff.bind("<Return>", SettingsTextKey)
22751  ZSTuff.bind('<MouseWheel>', Settingsscroll)
22752  ZSTuff.bind("<Button-4>", Settingsscroll)# with Linux OS
22753  ZSTuff.bind("<Button-5>", Settingsscroll)
22754  ZSTuff.bind('<Key>', SettingsTextKey)
22755  ZSTuff.pack(side=RIGHT)
22756  ZSTuff.delete(0,"end")
22757  ZSTuff.insert(0,ZEROstuffing.get())
22758  #
22759  Avglab = Label(frame1, text="Number Traces to Average", style= "A10B.TLabel")
22760  Avglab.grid(row=1, column=0, sticky=W)
22761  AvgMode = Frame( frame1 )
22762  AvgMode.grid(row=1, column=1, sticky=W)
22763  TAvg = Entry(AvgMode, width=4, cursor='double_arrow')
22764  TAvg.bind("<Return>", SettingsTextKey)
22765  TAvg.bind('<MouseWheel>', Settingsscroll)
22766  TAvg.bind("<Button-4>", Settingsscroll)# with Linux OS
22767  TAvg.bind("<Button-5>", Settingsscroll)
22768  TAvg.bind('<Key>', SettingsTextKey)
22769  TAvg.pack(side=RIGHT)
22770  TAvg.delete(0,"end")
22771  TAvg.insert(0,TRACEaverage.get())
22772  #
22773  HarMlab = Label(frame1, text="Number of Harmonic Markers", style= "A10B.TLabel")
22774  HarMlab.grid(row=2, column=0, sticky=W)
22775  HarMMode = Frame( frame1 )
22776  HarMMode.grid(row=2, column=1, sticky=W)
22777  HarMon = Entry(HarMMode, width=4, cursor='double_arrow')
22778  HarMon.bind("<Return>", SettingsTextKey)
22779  HarMon.bind('<MouseWheel>', Settingsscroll)
22780  HarMon.bind("<Button-4>", Settingsscroll)# with Linux OS
22781  HarMon.bind("<Button-5>", Settingsscroll)
22782  HarMon.bind('<Key>', SettingsTextKey)
22783  HarMon.pack(side=RIGHT)
22784  HarMon.delete(0,"end")
22785  HarMon.insert(0,HarmonicMarkers.get())
22786  #
22787  Vdivlab = Label(frame1, text="Number Vertical Div (SA, Bode)", style= "A10B.TLabel")
22788  Vdivlab.grid(row=3, column=0, sticky=W)
22789  VdivMode = Frame( frame1 )
22790  VdivMode.grid(row=3, column=1, sticky=W)
22791  VDivE = Entry(VdivMode, width=4, cursor='double_arrow')
22792  VDivE.bind("<Return>", SettingsTextKey)
22793  VDivE.bind('<MouseWheel>', Settingsscroll)
22794  VDivE.bind("<Button-4>", Settingsscroll)# with Linux OS
22795  VDivE.bind("<Button-5>", Settingsscroll)
22796  VDivE.bind('<Key>', SettingsTextKey)
22797  VDivE.pack(side=RIGHT)
22798  VDivE.delete(0,"end")
22799  VDivE.insert(0,Vdiv.get())
22800  #
22801  Twdthlab = Label(frame1, text="Trace Width in Pixels", style= "A10B.TLabel")
22802  Twdthlab.grid(row=4, column=0, sticky=W)
22803  TwdthMode = Frame( frame1 )
22804  TwdthMode.grid(row=4, column=1, sticky=W)
22805  TwdthE = Entry(TwdthMode, width=4, cursor='double_arrow')
22806  TwdthE.bind("<Return>", SettingsTextKey)
22807  TwdthE.bind('<MouseWheel>', Settingsscroll)
22808  TwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
22809  TwdthE.bind("<Button-5>", Settingsscroll)
22810  TwdthE.bind('<Key>', SettingsTextKey)
22811  TwdthE.pack(side=RIGHT)
22812  TwdthE.delete(0,"end")
22813  TwdthE.insert(0,TRACEwidth.get())
22814  #
22815  Gwdthlab = Label(frame1, text="Grid Width in Pixels", style= "A10B.TLabel")
22816  Gwdthlab.grid(row=5, column=0, sticky=W)
22817  GwdthMode = Frame( frame1 )
22818  GwdthMode.grid(row=5, column=1, sticky=W)
22819  GwdthE = Entry(GwdthMode, width=4, cursor='double_arrow')
22820  GwdthE.bind("<Return>", SettingsTextKey)
22821  GwdthE.bind('<MouseWheel>', Settingsscroll)
22822  GwdthE.bind("<Button-4>", Settingsscroll)# with Linux OS
22823  GwdthE.bind("<Button-5>", Settingsscroll)
22824  GwdthE.bind('<Key>', SettingsTextKey)
22825  GwdthE.pack(side=RIGHT)
22826  GwdthE.delete(0,"end")
22827  GwdthE.insert(0,GridWidth.get())
22828  #
22829  trglpflab = Label(frame1, text="Trigger LPF Length", style= "A10B.TLabel")
22830  trglpflab.grid(row=6, column=0, sticky=W)
22831  TrgLPFMode = Frame( frame1 )
22832  TrgLPFMode.grid(row=6, column=1, sticky=W)
22833  TrgLPFEntry = Entry(TrgLPFMode, width=4, cursor='double_arrow')
22834  TrgLPFEntry.bind("<Return>", SettingsTextKey)
22835  TrgLPFEntry.bind('<MouseWheel>', Settingsscroll)
22836  TrgLPFEntry.bind("<Button-4>", Settingsscroll)# with Linux OS
22837  TrgLPFEntry.bind("<Button-5>", Settingsscroll)
22838  TrgLPFEntry.bind('<Key>', SettingsTextKey)
22839  TrgLPFEntry.pack(side=RIGHT)
22840  TrgLPFEntry.delete(0,"end")
22841  TrgLPFEntry.insert(0,Trigger_LPF_length.get())
22842  #
22843  AwgAmplrb1 = Radiobutton(frame1, text="AWG Min/Max", variable=AWG_Amp_Mode, value=0, command=UpdateAWGWin)
22844  AwgAmplrb1.grid(row=7, column=0, sticky=W)
22845  AwgAmplrb2 = Radiobutton(frame1, text="AWG Amp/Off ", variable=AWG_Amp_Mode, value=1, command=UpdateAWGWin)
22846  AwgAmplrb2.grid(row=7, column=1, sticky=W)
22847  #
22848  cha_Rcomplab = Label(frame1, text="CHA Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
22849  cha_Rcomplab.grid(row=8, column=0, sticky=W)
22850  cha_RcomplabMode = Frame( frame1 )
22851  cha_RcomplabMode.grid(row=8, column=1, sticky=W)
22852  cha_TC1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
22853  cha_TC1Entry.bind("<Return>", SettingsTextKey)
22854  cha_TC1Entry.bind('<MouseWheel>', Settingsscroll)
22855  cha_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22856  cha_TC1Entry.bind("<Button-5>", Settingsscroll)
22857  cha_TC1Entry.bind('<Key>', SettingsTextKey)
22858  cha_TC1Entry.pack(side=LEFT)
22859  cha_TC1Entry.delete(0,"end")
22860  cha_TC1Entry.insert(0,CHA_TC1.get())
22861  cha_A1Entry = Entry(cha_RcomplabMode, width=5, cursor='double_arrow')
22862  cha_A1Entry.bind("<Return>", SettingsTextKey)
22863  cha_A1Entry.bind('<MouseWheel>', Settingsscroll)
22864  cha_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22865  cha_A1Entry.bind("<Button-5>", Settingsscroll)
22866  cha_A1Entry.bind('<Key>', SettingsTextKey)
22867  cha_A1Entry.pack(side=LEFT)
22868  cha_A1Entry.delete(0,"end")
22869  cha_A1Entry.insert(0,CHA_A1.get())
22870  #
22871  cha_Ccomplab = Label(frame1, text="CHA Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
22872  cha_Ccomplab.grid(row=9, column=0, sticky=W)
22873  cha_CcomplabMode = Frame( frame1 )
22874  cha_CcomplabMode.grid(row=9, column=1, sticky=W)
22875  cha_TC2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
22876  cha_TC2Entry.bind("<Return>", SettingsTextKey)
22877  cha_TC2Entry.bind('<MouseWheel>', Settingsscroll)
22878  cha_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22879  cha_TC2Entry.bind("<Button-5>", Settingsscroll)
22880  cha_TC2Entry.bind('<Key>', SettingsTextKey)
22881  cha_TC2Entry.pack(side=LEFT)
22882  cha_TC2Entry.delete(0,"end")
22883  cha_TC2Entry.insert(0,CHA_TC2.get())
22884  cha_A2Entry = Entry(cha_CcomplabMode, width=5, cursor='double_arrow')
22885  cha_A2Entry.bind("<Return>", SettingsTextKey)
22886  cha_A2Entry.bind('<MouseWheel>', Settingsscroll)
22887  cha_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22888  cha_A2Entry.bind("<Button-5>", Settingsscroll)
22889  cha_A2Entry.bind('<Key>', SettingsTextKey)
22890  cha_A2Entry.pack(side=LEFT)
22891  cha_A2Entry.delete(0,"end")
22892  cha_A2Entry.insert(0,CHA_A2.get())
22893  #
22894  chb_Rcomplab = Label(frame1, text="CHB Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
22895  chb_Rcomplab.grid(row=10, column=0, sticky=W)
22896  chb_RcomplabMode = Frame( frame1 )
22897  chb_RcomplabMode.grid(row=10, column=1, sticky=W)
22898  chb_TC1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
22899  chb_TC1Entry.bind("<Return>", SettingsTextKey)
22900  chb_TC1Entry.bind('<MouseWheel>', Settingsscroll)
22901  chb_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22902  chb_TC1Entry.bind("<Button-5>", Settingsscroll)
22903  chb_TC1Entry.bind('<Key>', SettingsTextKey)
22904  chb_TC1Entry.pack(side=LEFT)
22905  chb_TC1Entry.delete(0,"end")
22906  chb_TC1Entry.insert(0,CHB_TC1.get())
22907  chb_A1Entry = Entry(chb_RcomplabMode, width=5, cursor='double_arrow')
22908  chb_A1Entry.bind("<Return>", SettingsTextKey)
22909  chb_A1Entry.bind('<MouseWheel>', Settingsscroll)
22910  chb_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22911  chb_A1Entry.bind("<Button-5>", Settingsscroll)
22912  chb_A1Entry.bind('<Key>', SettingsTextKey)
22913  chb_A1Entry.pack(side=LEFT)
22914  chb_A1Entry.delete(0,"end")
22915  chb_A1Entry.insert(0,CHB_A1.get())
22916  #
22917  chb_Ccomplab = Label(frame1, text="CHB Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
22918  chb_Ccomplab.grid(row=11, column=0, sticky=W)
22919  chb_CcomplabMode = Frame( frame1 )
22920  chb_CcomplabMode.grid(row=11, column=1, sticky=W)
22921  chb_TC2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
22922  chb_TC2Entry.bind("<Return>", SettingsTextKey)
22923  chb_TC2Entry.bind('<MouseWheel>', Settingsscroll)
22924  chb_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22925  chb_TC2Entry.bind("<Button-5>", Settingsscroll)
22926  chb_TC2Entry.bind('<Key>', SettingsTextKey)
22927  chb_TC2Entry.pack(side=LEFT)
22928  chb_TC2Entry.delete(0,"end")
22929  chb_TC2Entry.insert(0,CHB_TC2.get())
22930  chb_A2Entry = Entry(chb_CcomplabMode, width=5, cursor='double_arrow')
22931  chb_A2Entry.bind("<Return>", SettingsTextKey)
22932  chb_A2Entry.bind('<MouseWheel>', Settingsscroll)
22933  chb_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22934  chb_A2Entry.bind("<Button-5>", Settingsscroll)
22935  chb_A2Entry.bind('<Key>', SettingsTextKey)
22936  chb_A2Entry.pack(side=LEFT)
22937  chb_A2Entry.delete(0,"end")
22938  chb_A2Entry.insert(0,CHB_A2.get())
22939  #
22940  if EnableHSsampling > 0:
22941  hs_ckb1 = Checkbutton(frame1, text="Auto Set ETS Comp", variable=Auto_ETS_Comp, command=SetETSComp)
22942  hs_ckb1.grid(row=12, column=0, sticky=W)
22943  hs1_Complab = Label(frame1, text="ETS Comp, TC1 (uSec), A1", style= "A10B.TLabel") # in micro seconds
22944  hs1_Complab.grid(row=13, column=0, sticky=W)
22945  hs1_ComplabMode = Frame( frame1 )
22946  hs1_ComplabMode.grid(row=13, column=1, sticky=W)
22947  ets_TC1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
22948  ets_TC1Entry.bind("<Return>", SettingsTextKey)
22949  ets_TC1Entry.bind('<MouseWheel>', Settingsscroll)
22950  ets_TC1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22951  ets_TC1Entry.bind("<Button-5>", Settingsscroll)
22952  ets_TC1Entry.bind('<Key>', SettingsTextKey)
22953  ets_TC1Entry.pack(side=LEFT)
22954  ets_TC1Entry.delete(0,"end")
22955  ets_TC1Entry.insert(0,ETS_TC1.get())
22956  ets_A1Entry = Entry(hs1_ComplabMode, width=5, cursor='double_arrow')
22957  ets_A1Entry.bind("<Return>", SettingsTextKey)
22958  ets_A1Entry.bind('<MouseWheel>', Settingsscroll)
22959  ets_A1Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22960  ets_A1Entry.bind("<Button-5>", Settingsscroll)
22961  ets_A1Entry.bind('<Key>', SettingsTextKey)
22962  ets_A1Entry.pack(side=LEFT)
22963  ets_A1Entry.delete(0,"end")
22964  ets_A1Entry.insert(0,ETS_A1.get())
22965  #
22966  hs2_Complab = Label(frame1, text="ETS Comp, TC2 (uSec), A2", style= "A10B.TLabel") # in micro seconds
22967  hs2_Complab.grid(row=14, column=0, sticky=W)
22968  hs2_ComplabMode = Frame( frame1 )
22969  hs2_ComplabMode.grid(row=14, column=1, sticky=W)
22970  ets_TC2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
22971  ets_TC2Entry.bind("<Return>", SettingsTextKey)
22972  ets_TC2Entry.bind('<MouseWheel>', Settingsscroll)
22973  ets_TC2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22974  ets_TC2Entry.bind("<Button-5>", Settingsscroll)
22975  ets_TC2Entry.bind('<Key>', SettingsTextKey)
22976  ets_TC2Entry.pack(side=LEFT)
22977  ets_TC2Entry.delete(0,"end")
22978  ets_TC2Entry.insert(0,ETS_TC2.get())
22979  ets_A2Entry = Entry(hs2_ComplabMode, width=5, cursor='double_arrow')
22980  ets_A2Entry.bind("<Return>", SettingsTextKey)
22981  ets_A2Entry.bind('<MouseWheel>', Settingsscroll)
22982  ets_A2Entry.bind("<Button-4>", Settingsscroll)# with Linux OS
22983  ets_A2Entry.bind("<Button-5>", Settingsscroll)
22984  ets_A2Entry.bind('<Key>', SettingsTextKey)
22985  ets_A2Entry.pack(side=LEFT)
22986  ets_A2Entry.delete(0,"end")
22987  ets_A2Entry.insert(0,ETS_A2.get())
22988  #
22989  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
22990  Settingsdismissbutton.grid(row=15, column=0, sticky=W, pady=7)
22991  else:
22992  Settingsdismissbutton = Button(frame1, text="Dismiss", style= "W8.TButton", command=DestroySettings)
22993  Settingsdismissbutton.grid(row=12, column=0, sticky=W, pady=7)
22994 #
22996  global Auto_ETS_Comp, ETS_TC1, ETS_A1, ETS_TC2, ETS_A2
22997  global ets_TC1Entry, ets_A1Entry, ets_TC2Entry, ets_A2Entry
22998  global CHA_RC_HP, CHB_RC_HP, CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
22999  global CHA_A1, CHA_A2, CHB_A1, CHB_A2
23000  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23001  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23002 
23003  if Auto_ETS_Comp.get() == 1:
23004  try:
23005  MulX = float(HtMulEntry.get())
23006  #
23007  Value = float(ets_TC1Entry.get()) * MulX
23008  cha_TC1Entry.delete(0,"end")
23009  cha_TC1Entry.insert(0, Value)
23010  cha_A1Entry.delete(0,"end")
23011  cha_A1Entry.insert(0, ets_A1Entry.get())
23012  chb_TC1Entry.delete(0,"end")
23013  chb_TC1Entry.insert(0, Value)
23014  chb_A1Entry.delete(0,"end")
23015  chb_A1Entry.insert(0, ets_A1Entry.get())
23016  #
23017  Value = float(ets_TC2Entry.get()) * MulX
23018  cha_TC2Entry.delete(0,"end")
23019  cha_TC2Entry.insert(0, Value)
23020  cha_A2Entry.delete(0,"end")
23021  cha_A2Entry.insert(0, ets_A2Entry.get())
23022  chb_TC2Entry.delete(0,"end")
23023  chb_TC2Entry.insert(0, Value)
23024  chb_A2Entry.delete(0,"end")
23025  chb_A2Entry.insert(0, ets_A2Entry.get())
23026  except:
23027  MulX = 1.0
23028 
23030 
23031  UpdateAWGA()
23032  UpdateAWGB()
23033  ReMakeAWGwaves()
23034 
23036  global GridWidth, TRACEwidth, TRACEaverage, Vdiv, HarmonicMarkers, ZEROstuffing, RevDate
23037  global Settingswindow, SettingsStatus, ZSTuff, TAvg, VDivE, TwdthE, GwdthE, HarMon
23038  global CHA_TC1, CHA_TC2, CHB_TC1, CHB_TC2
23039  global CHA_A1, CHA_A2, CHB_A1, CHB_A2, TrgLPFEntry, Trigger_LPF_length
23040  global cha_TC1Entry, cha_TC2Entry, chb_TC1Entry, chb_TC2Entry
23041  global cha_A1Entry, cha_A2Entry, chb_A1Entry, chb_A2Entry
23042 
23043  try:
23044  GW = int(eval(GwdthE.get()))
23045  if GW < 1:
23046  GW = 1
23047  GwdthE.delete(0,END)
23048  GwdthE.insert(0, int(GW))
23049  if GW > 5:
23050  GW = 5
23051  GwdthE.delete(0,END)
23052  GwdthE.insert(0, int(GW))
23053  except:
23054  GwdthE.delete(0,END)
23055  GwdthE.insert(0, GridWidth.get())
23056  GridWidth.set(GW)
23057  #
23058  try:
23059  T_length = int(eval(TrgLPFEntry.get()))
23060  if T_length < 1:
23061  T_length = 1
23062  TrgLPFEntry.delete(0,END)
23063  TrgLPFEntry.insert(0, int(GW))
23064  if T_length > 100:
23065  T_length = 100
23066  TrgLPFEntry.delete(0,END)
23067  TrgLPFEntry.insert(0, int(GW))
23068  except:
23069  TrgLPFEntry.delete(0,END)
23070  TrgLPFEntry.insert(0, Trigger_LPF_length.get())
23071  Trigger_LPF_length.set(T_length)
23072  #
23073  try:
23074  TW = int(eval(TwdthE.get()))
23075  if TW < 1:
23076  TW = 1
23077  TwdthE.delete(0,END)
23078  TwdthE.insert(0, int(TW))
23079  if TW > 5:
23080  TW = 5
23081  TwdthE.delete(0,END)
23082  TwdthE.insert(0, int(TW))
23083  except:
23084  TwdthE.delete(0,END)
23085  TwdthE.insert(0, TRACEwidth.get())
23086  TRACEwidth.set(TW)
23087  # Number of average sweeps for average mode
23088  try:
23089  TA = int(eval(TAvg.get()))
23090  if TA < 1:
23091  TA = 1
23092  TAvg.delete(0,END)
23093  TAvg.insert(0, int(TA))
23094  if TA > 16:
23095  TA = 16
23096  TAvg.delete(0,END)
23097  TAvg.insert(0, int(TA))
23098  except:
23099  TAvg.delete(0,END)
23100  TAvg.insert(0, TRACEaverage.get())
23101  TRACEaverage.set(TA)
23102  # Number of vertical divisions for spectrum / Bode
23103  try:
23104  VDv = int(eval(VDivE.get()))
23105  if VDv < 1:
23106  VDv = 1
23107  VDivE.delete(0,END)
23108  VDivE.insert(0, int(VDv))
23109  if VDv > 16:
23110  VDv = 16
23111  VDivE.delete(0,END)
23112  VDivE.insert(0, int(VDv))
23113  except:
23114  VDivE.delete(0,END)
23115  VDivE.insert(0, Vdiv.get())
23116  Vdiv.set(VDv)
23117  # number of Harmonic Markers in SA
23118  try:
23119  HM = int(eval(HarMon.get()))
23120  if HM < 1:
23121  HM = 1
23122  HarMon.delete(0,END)
23123  HarMon.insert(0, int(HM))
23124  if HM > 9:
23125  HM =9
23126  HarMon.delete(0,END)
23127  HarMon.insert(0, int(HM))
23128  except:
23129  HarMon.delete(0,END)
23130  HarMon.insert(0, HarmonicMarkers.get())
23131  HarmonicMarkers.set(HM)
23132  # The zero stuffing value is 2 ** ZERO stuffing, calculated on initialize
23133  try:
23134  ZST = int(eval(ZSTuff.get()))
23135  if ZST < 1:
23136  ZST = 1
23137  ZSTuff.delete(0,END)
23138  ZSTuff.insert(0, int(ZST))
23139  if ZST > 5:
23140  ZST = 5
23141  ZSTuff.delete(0,END)
23142  ZSTuff.insert(0, int(ZST))
23143  except:
23144  ZSTuff.delete(0,END)
23145  ZSTuff.insert(0, ZEROstuffing.get())
23146  ZEROstuffing.set(ZST)
23147 #
23148  try:
23149  TC1A = float(cha_TC1Entry.get())
23150  CHA_TC1.set(TC1A)
23151  if TC1A < 0:
23152  TC1A = 0
23153  cha_TC1Entry.delete(0,END)
23154  cha_TC1Entry.insert(0, TC1A)
23155  except:
23156  cha_TC1Entry.delete(0,END)
23157  cha_TC1Entry.insert(0, CHA_TC1.get())
23158  try:
23159  TC2A = float(cha_TC2Entry.get())
23160  CHA_TC2.set(TC2A)
23161  if TC2A < 0:
23162  TC2A = 0
23163  cha_TC2Entry.delete(0,END)
23164  cha_TC2Entry.insert(0, TC2A)
23165  except:
23166  cha_TC2Entry.delete(0,END)
23167  cha_TC2Entry.insert(0, CHA_TC2.get())
23168  #
23169  try:
23170  Gain1A = float(cha_A1Entry.get())
23171  CHA_A1.set(Gain1A)
23172  except:
23173  cha_A1Entry.delete(0,END)
23174  cha_A1Entry.insert(0, CHA_A1.get())
23175  try:
23176  Gain2A = float(cha_A2Entry.get())
23177  CHA_A2.set(Gain2A)
23178  except:
23179  cha_A2Entry.delete(0,END)
23180  cha_A2Entry.insert(0, CHA_A2.get())
23181  #
23182  try:
23183  TC1B = float(chb_TC1Entry.get())
23184  CHB_TC1.set(TC1B)
23185  if TC1B < 0:
23186  TC1B = 0
23187  chb_TC1Entry.delete(0, END)
23188  chb_TC1Entry.insert(0, TC1B)
23189  except:
23190  chb_TC1Entry.delete(0,END)
23191  chb_TC1Entry.insert(0, CHB_TC1.get())
23192  try:
23193  TC2B = float(chb_TC2Entry.get())
23194  CHB_TC2.set(TC2B)
23195  if TC2B < 0:
23196  TC2B = 0
23197  chb_TC2Entry.delete(0, END)
23198  chb_TC2Entry.insert(0, TC2B)
23199  except:
23200  chb_TC2Entry.delete(0,END)
23201  chb_TC2Entry.insert(0, CHB_TC2.get())
23202  #
23203  try:
23204  Gain1B = float(chb_A1Entry.get())
23205  CHB_A1.set(Gain1B)
23206  except:
23207  chb_A1Entry.delete(0,END)
23208  chb_A1Entry.insert(0, CHB_A1.get())
23209  try:
23210  Gain2B = float(chb_A2Entry.get())
23211  CHB_A2.set(Gain2B)
23212  except:
23213  chb_A2Entry.delete(0,END)
23214  chb_A2Entry.insert(0, CHB_A2.get())
23215  # set ETS base comp
23216  #
23217  SetETSComp()
23218 #
23220  global Settingswindow, SettingsStatus
23221 
23222  SettingsStatus.set(0)
23223  SettingsUpdate()
23224  Settingswindow.destroy()
23225 #
23226 def onCanvasMouse_xy(event):
23227  global MouseX, MouseY, MouseWidget
23228 
23229  MouseWidget = event.widget
23230  MouseX, MouseY = event.x, event.y
23231 #
23232 def BSetFmin():
23233  global FminEntry, CHAfreq
23234 
23235  if CHAfreq > 0:
23236  String = '{0:.3f}'.format(CHAfreq/1000)
23237  FminEntry.delete(0,"end")
23238  FminEntry.insert(0,String)
23239 #
23240 def ReSetAGO():
23241  global CHAVGainEntry, CHAVOffsetEntry
23242 
23243  CHAVGainEntry.delete(0,"end")
23244  CHAVGainEntry.insert(0,1.0)
23245  CHAVOffsetEntry.delete(0,"end")
23246  CHAVOffsetEntry.insert(0,0.0)
23247 #
23248 def ReSetBGO():
23249  global CHBVGainEntry, CHBVOffsetEntry
23250 
23251  CHBVGainEntry.delete(0,"end")
23252  CHBVGainEntry.insert(0,1.0)
23253  CHBVOffsetEntry.delete(0,"end")
23254  CHBVOffsetEntry.insert(0,0.0)
23255 #
23257  global CHAIGainEntry, CHAIOffsetEntry
23258 
23259  CHAIGainEntry.delete(0,"end")
23260  CHAIGainEntry.insert(0,1.0)
23261  CHAIOffsetEntry.delete(0,"end")
23262  CHAIOffsetEntry.insert(0,0.0)
23263 #
23265  global CHBIGainEntry, CHBIOffsetEntry
23266 
23267  CHBIGainEntry.delete(0,"end")
23268  CHBIGainEntry.insert(0,1.0)
23269  CHBIOffsetEntry.delete(0,"end")
23270  CHBIOffsetEntry.insert(0,0.0)
23271 #
23273  global EnablePhaseAnalizer, EnableSpectrumAnalizer, EnableBodePlotter, EnableImpedanceAnalizer
23274  global EnableOhmMeter, OOTphckb, OOTBuildPhAScreen, OOTckb3, OOTBuildSpectrumScreen, OOTckb5, ckb1
23275  global OOTBuildBodeScreen, OOTckb4, OOTBuildIAScreen, OOTckb6, OOTBuildOhmScreen, OOTScreenStatus
23276  global OOTwindow, SWRev, RevDate, BorderSize, FrameRefief, OOTdismissclbutton, EnableDigIO
23277  global EnablePIODACMode, EnableMuxMode, EnableMinigenMode, EnablePmodDA1Mode, EnableDigPotMode, EnableGenericSerialMode
23278  global EnableAD5626SerialMode, EnableDigitalFilter, EnableCommandInterface, EnableMeasureScreen, EnableETSScreen
23279 
23280  if OOTScreenStatus.get() == 0:
23281  OOTScreenStatus.set(1)
23282  OOTwindow = Toplevel()
23283  OOTwindow.title("Instruments " + SWRev + RevDate)
23284  OOTwindow.resizable(FALSE,FALSE)
23285  OOTwindow.protocol("WM_DELETE_WINDOW", DestroyOOTwindow)
23286  frame1 = Frame(OOTwindow, borderwidth=BorderSize, relief=FrameRefief)
23287  frame1.grid(row=0, column=0, sticky=W)
23288  #
23289  nextrow = 1
23290  timebtn = Frame( frame1 )
23291  timebtn.grid(row=nextrow, column=0, sticky=W)
23292  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
23293  ckb1.pack(side=LEFT)
23294  timelab = Label(timebtn, text="Time Plot")
23295  timelab.pack(side=LEFT)
23296  nextrow = nextrow + 1
23297  if EnablePhaseAnalizer > 0:
23298  phasebtn = Frame( frame1 )
23299  phasebtn.grid(row=nextrow, column=0, sticky=W)
23300  OOTphckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
23301  OOTphckb.pack(side=LEFT)
23302  OOTBuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
23303  OOTBuildPhAScreen.pack(side=LEFT)
23304  nextrow = nextrow + 1
23305  #
23306  if EnableSpectrumAnalizer > 0:
23307  freqbtn = Frame( frame1 )
23308  freqbtn.grid(row=nextrow, column=0, sticky=W)
23309  OOTckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
23310  OOTckb3.pack(side=LEFT)
23311  OOTBuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
23312  OOTBuildSpectrumScreen.pack(side=LEFT)
23313  nextrow = nextrow + 1
23314  #
23315  if EnableBodePlotter > 0:
23316  bodebtn = Frame( frame1 )
23317  bodebtn.grid(row=nextrow, column=0, sticky=W)
23318  OOTckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
23319  OOTckb5.pack(side=LEFT)
23320  OOTBuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
23321  OOTBuildBodeScreen.pack(side=LEFT)
23322  nextrow = nextrow + 1
23323  #
23324  if EnableImpedanceAnalizer > 0:
23325  impdbtn = Frame( frame1 )
23326  impdbtn.grid(row=nextrow, column=0, sticky=W)
23327  OOTckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
23328  OOTckb4.pack(side=LEFT)
23329  OOTBuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
23330  OOTBuildIAScreen.pack(side=LEFT)
23331  nextrow = nextrow + 1
23332  #
23333  if EnableOhmMeter > 0:
23334  dcohmbtn = Frame( frame1 )
23335  dcohmbtn.grid(row=nextrow, column=0, sticky=W)
23336  OOTckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
23337  OOTckb6.pack(side=LEFT)
23338  OOTBuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
23339  OOTBuildOhmScreen.pack(side=LEFT)
23340  nextrow = nextrow + 1
23341 
23342  if EnableDigIO > 0:
23343  OOTBuildDigScreen = Button(frame1, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
23344  OOTBuildDigScreen.grid(row=nextrow, column=0, sticky=W)
23345  nextrow = nextrow + 1
23346  # Optional plugin tools
23347  if EnablePIODACMode > 0:
23348  OOTBuildDacScreen = Button(frame1, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
23349  OOTBuildDacScreen.grid(row=nextrow, column=0, sticky=W)
23350  nextrow = nextrow + 1
23351  if EnableMuxMode > 0:
23352  OOTBuildMuxScreen = Button(frame1, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
23353  OOTBuildMuxScreen.grid(row=nextrow, column=0, sticky=W)
23354  nextrow = nextrow + 1
23355  if EnableMinigenMode > 0:
23356  OOTBuildMinigenScreen = Button(frame1, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
23357  OOTBuildMinigenScreen.grid(row=nextrow, column=0, sticky=W)
23358  nextrow = nextrow + 1
23359  if EnablePmodDA1Mode > 0:
23360  OOTBuildDA1Screen = Button(frame1, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
23361  OOTBuildDA1Screen.grid(row=nextrow, column=0, sticky=W)
23362  nextrow = nextrow + 1
23363  if EnableDigPotMode >0:
23364  OOTBuildDigPotScreen = Button(frame1, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
23365  OOTBuildDigPotScreen.grid(row=nextrow, column=0, sticky=W)
23366  nextrow = nextrow + 1
23367  if EnableGenericSerialMode >0:
23368  OOTGenericSerialScreen = Button(frame1, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
23369  OOTGenericSerialScreen.grid(row=nextrow, column=0, sticky=W)
23370  nextrow = nextrow + 1
23371  if EnableAD5626SerialMode >0:
23372  OOTAD5626SerialScreen = Button(frame1, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
23373  OOTAD5626SerialScreen.grid(row=nextrow, column=0, sticky=W)
23374  nextrow = nextrow + 1
23375  if EnableDigitalFilter >0:
23376  OOTDigFiltScreen = Button(frame1, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
23377  OOTDigFiltScreen.grid(row=nextrow, column=0, sticky=W)
23378  nextrow = nextrow + 1
23379  if EnableCommandInterface > 0:
23380  OOTCommandLineScreen = Button(frame1, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
23381  OOTCommandLineScreen.grid(row=nextrow, column=0, sticky=W)
23382  nextrow = nextrow + 1
23383  if EnableMeasureScreen > 0:
23384  OOTMeasureScreen = Button(frame1, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
23385  OOTMeasureScreen.grid(row=nextrow, column=0, sticky=W)
23386  nextrow = nextrow + 1
23387  if EnableETSScreen > 0:
23388  OOTETSScreen = Button(frame1, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
23389  OOTETSScreen.grid(row=nextrow, column=0, sticky=W)
23390  nextrow = nextrow + 1
23391  #
23392  OOTdismissclbutton = Button(frame1, text="Dismiss", style="W8.TButton", command=DestroyOOTwindow)
23393  OOTdismissclbutton.grid(row=nextrow, column=0, sticky=W, pady=7)
23394 #
23396  global OOTwindow, OOTScreenStatus
23397 
23398  OOTScreenStatus.set(0)
23399  OOTwindow.destroy()
23400 #
23401 #
23402 # ================ Make main Screen ==========================
23403 TgInput = IntVar(0) # Trigger Input variable
23404 SingleShot = IntVar(0) # variable for single shot triger
23405 ManualTrigger = IntVar(0) # variable for Manual trigger
23406 AutoLevel = IntVar(0) # variable for Auto Level trigger at mid point
23407 ShowC1_V = IntVar(0) # curves to display variables
23408 TgEdge = IntVar(0) # Trigger edge variable
23409 # Show channels variables
23410 ShowC1_V = IntVar(0) # curves to display variables
23411 ShowC1_I = IntVar(0)
23412 ShowC2_V = IntVar(0)
23413 ShowC2_I = IntVar(0)
23414 ShowAV_I = IntVar(0)
23415 ShowBV_I = IntVar(0)
23416 ShowRA_V = IntVar(0)
23417 ShowRA_I = IntVar(0)
23418 ShowRB_V = IntVar(0)
23419 ShowRB_I = IntVar(0)
23420 ShowMath = IntVar(0)
23421 ShowPB_A = IntVar(0)
23422 ShowPB_B = IntVar(0)
23423 ShowPB_C = IntVar(0)
23424 ShowPB_D = IntVar(0)
23425 # Bode and SA variables
23426 ShowC1_VdB = IntVar(0) # curves to display variables
23427 ShowC1_P = IntVar(0)
23428 ShowC2_VdB = IntVar(0)
23429 ShowC2_P = IntVar(0)
23430 ShowMarker = IntVar(0)
23431 ShowRA_VdB = IntVar(0)
23432 ShowRA_P = IntVar(0)
23433 ShowRB_VdB = IntVar(0)
23434 ShowRB_P = IntVar(0)
23435 ShowMathSA = IntVar(0)
23436 ShowRMath = IntVar(0)
23437 ShowAWGASA = IntVar(0)
23438 ShowAWGBSA = IntVar(0)
23439 HScaleBP = IntVar(0)
23440 HScaleBP.set(1)
23441 #
23442 Show_MathX = IntVar(0)
23443 Show_MathY = IntVar(0)
23444 AutoCenterA = IntVar(0)
23445 AutoCenterB = IntVar(0)
23446 SmoothCurves = IntVar(0)
23447 ZOHold = IntVar(0)
23448 TRACEmodeTime = IntVar(0)
23449 TRACEmodeTime.set(0)
23450 DecimateOption = IntVar(0)
23451 MathTrace = IntVar(0)
23452 # AWG variables
23453 AWGAMode = IntVar(0) # AWG A mode variable
23454 AWGAIOMode = IntVar(0) # AWG A Split I/O mode variable
23455 AWGATerm = IntVar(0) # AWG A termination variable
23456 AWGAShape = IntVar(0) # AWG A Wave shape variable
23457 AWGAPhaseDelay = IntVar(0) #
23458 AWGARepeatFlag = IntVar(0) # AWG A Arb shape repeat flag
23459 AWGABurstFlag = IntVar(0) # AWG A Burst mode flag
23460 AWGBBurstFlag = IntVar(0) # AWG B Burst mode flag
23461 AWGBMode = IntVar(0) # AWG B mode variable
23462 AWGBIOMode = IntVar(0) # AWG B Split I/O mode variable
23463 AWGBTerm = IntVar(0) # AWG B termination variable
23464 AWGBShape = IntVar(0) # AWG B Wave shape variable
23465 AWGBPhaseDelay = IntVar(0) #
23466 AWGBRepeatFlag = IntVar(0) # AWG B Arb shape repeat flag
23467 AWGAMode.set(2)
23468 AWGBMode.set(2)
23469 AWGSync = IntVar(0) # Sync start both AWG channels
23470 AWGSync.set(1)
23471 BisCompA = IntVar(0) # Make Channel B comp of channel A
23472 BisCompA.set(0)
23473 # define vertical measurment variables
23474 MeasDCV1 = IntVar(0)
23475 MeasMinV1 = IntVar(0)
23476 MeasMaxV1 = IntVar(0)
23477 MeasMidV1 = IntVar(0)
23478 MeasPPV1 = IntVar(0)
23479 MeasRMSV1 = IntVar(0)
23480 MeasRMSVA_B = IntVar(0)
23481 MeasDCI1 = IntVar(0)
23482 MeasMinI1 = IntVar(0)
23483 MeasMaxI1 = IntVar(0)
23484 MeasMidI1 = IntVar(0)
23485 MeasPPI1 = IntVar(0)
23486 MeasRMSI1 = IntVar(0)
23487 MeasDiffAB = IntVar(0)
23488 MeasDCV2 = IntVar(0)
23489 MeasMinV2 = IntVar(0)
23490 MeasMaxV2 = IntVar(0)
23491 MeasMidV2 = IntVar(0)
23492 MeasPPV2 = IntVar(0)
23493 MeasRMSV2 = IntVar(0)
23494 MeasDCI2 = IntVar(0)
23495 MeasMinI2 = IntVar(0)
23496 MeasMaxI2 = IntVar(0)
23497 MeasMidI2 = IntVar(0)
23498 MeasPPI2 = IntVar(0)
23499 MeasRMSI2 = IntVar(0)
23500 MeasDiffBA = IntVar(0)
23501 MeasUserA = IntVar(0)
23502 MeasAHW = IntVar(0)
23503 MeasALW = IntVar(0)
23504 MeasADCy = IntVar(0)
23505 MeasAPER = IntVar(0)
23506 MeasAFREQ = IntVar(0)
23507 MeasBHW = IntVar(0)
23508 MeasBLW = IntVar(0)
23509 MeasBDCy = IntVar(0)
23510 MeasBPER = IntVar(0)
23511 MeasBFREQ = IntVar(0)
23512 MeasPhase = IntVar(0)
23513 MeasTopV1 = IntVar(0)
23514 MeasBaseV1 = IntVar(0)
23515 MeasTopV2 = IntVar(0)
23516 MeasBaseV2 = IntVar(0)
23517 MeasUserB = IntVar(0)
23518 MeasDelay = IntVar(0)
23519 TimeDisp = IntVar(0)
23520 TimeDisp.set(1)
23521 XYDisp = IntVar(0)
23522 FreqDisp = IntVar(0)
23523 PhADisp = IntVar(0)
23524 BodeDisp = IntVar(0)
23525 IADisp = IntVar(0)
23526 OhmDisp = IntVar(0)
23527 OOTScreenStatus = IntVar(0)
23528 OOTScreenStatus.set(0)
23529 PhAScreenStatus = IntVar(0)
23530 PhAScreenStatus.set(0)
23531 AppendPhAData = IntVar(0)
23532 AppendPhAData.set(0)
23533 PhAPlotMode = IntVar(0)
23534 PhADatafilename = "PhaseData.csv"
23535 BodeScreenStatus = IntVar(0)
23536 BodeScreenStatus.set(0)
23537 DigScreenStatus = IntVar(0)
23538 DigScreenStatus.set(0)
23539 DacScreenStatus = IntVar(0)
23540 DacScreenStatus.set(0)
23541 MuxScreenStatus = IntVar(0)
23542 MuxScreenStatus.set(0)
23543 MuxEnb = IntVar(0)
23544 MuxSync = IntVar(0)
23545 DualMuxMode = IntVar(0)
23546 ChopMuxMode = IntVar(0)
23547 ChopTrig = IntVar(0)
23548 MinigenScreenStatus = IntVar(0)
23549 MinigenScreenStatus.set(0)
23550 DA1ScreenStatus = IntVar(0)
23551 DA1ScreenStatus.set(0)
23552 DigPotScreenStatus = IntVar(0)
23553 DigPotScreenStatus.set(0)
23554 GenericSerialStatus = IntVar(0)
23555 GenericSerialStatus.set(0)
23556 AD5626SerialStatus = IntVar(0)
23557 AD5626SerialStatus.set(0)
23558 DigFiltStatus = IntVar(0)
23559 DigFiltStatus.set(0)
23560 CommandStatus = IntVar(0)
23561 CommandStatus.set(0)
23562 MeasureStatus = IntVar(0)
23563 MeasureStatus.set(0)
23564 MarkerScale = IntVar(0)
23565 MarkerScale.set(1)
23566 SettingsStatus = IntVar(0)
23567 CHA_RC_HP = IntVar(0)
23568 CHB_RC_HP = IntVar(0)
23569 CHAI_RC_HP = IntVar(0)
23570 CHBI_RC_HP = IntVar(0)
23571 HScale = IntVar(0)
23572 SAVScale = IntVar(0)
23573 SAVPSD = IntVar(0)
23574 SAvertmax = 1.0
23575 SAvertmin = 1.0E-6
23576 #
23577 if GUITheme == "Light": # Can be Light or Dark or Blue or LtBlue
23578  FrameBG = "#d7d7d7"
23579  ButtonText = "#000000"
23580 elif GUITheme == "Dark":
23581  FrameBG = "#484848"
23582  ButtonText = "#ffffff"
23583 elif GUITheme == "Blue":
23584  FrameBG = "#242468"
23585  ButtonText = "#d0d0ff"
23586 elif GUITheme == "LtBlue":
23587  FrameBG = "#c0e8ff"
23588  ButtonText = "#000040"
23589 EntryText = "#000000"
23590 BoxColor = "#0000ff" # 100% blue
23591 root.style.configure("TFrame", background=FrameBG, borderwidth=BorderSize)
23592 root.style.configure("TLabelframe", background=FrameBG)
23593 root.style.configure("TLabel", foreground=ButtonText, background=FrameBG, relief=LabRelief)
23594 root.style.configure("TEntry", foreground=EntryText, background=FrameBG, relief=ButRelief) #cursor='sb_v_double_arrow'
23595 root.style.configure("TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
23596 root.style.configure("TRadiobutton", foreground=ButtonText, background=FrameBG, indicatorcolor=FrameBG)
23597 root.style.configure("TButton", foreground=ButtonText, background=FrameBG, highlightcolor=FrameBG, relief=ButRelief)
23598 # define custom buttons and labels
23599 root.style.configure("TSpinbox", arrowsize=SBoxarrow) # 11 only changes things in Python 3
23600 root.style.configure("W3.TButton", width=3, relief=ButRelief)
23601 root.style.configure("W4.TButton", width=4, relief=ButRelief)
23602 root.style.configure("W5.TButton", width=5, relief=ButRelief)
23603 root.style.configure("W6.TButton", width=6, relief=ButRelief)
23604 root.style.configure("W7.TButton", width=7, relief=ButRelief)
23605 root.style.configure("W8.TButton", width=8, relief=ButRelief)
23606 root.style.configure("W9.TButton", width=9, relief=ButRelief)
23607 root.style.configure("W10.TButton", width=10, relief=ButRelief)
23608 root.style.configure("W11.TButton", width=11, relief=ButRelief)
23609 root.style.configure("W16.TButton", width=16, relief=ButRelief)
23610 root.style.configure("W17.TButton", width=17, relief=ButRelief)
23611 root.style.configure("Stop.TButton", background=ButtonRed, foreground="#000000", width=4, relief=ButRelief)
23612 root.style.configure("Run.TButton", background=ButtonGreen, foreground="#000000", width=4, relief=ButRelief)
23613 root.style.configure("Pwr.TButton", background=ButtonGreen, foreground="#000000", width=8, relief=ButRelief)
23614 root.style.configure("PwrOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
23615 root.style.configure("Roll.TButton", background=ButtonGreen, foreground="#000000", width=7, relief=ButRelief)
23616 root.style.configure("RollOff.TButton", background=ButtonRed, foreground="#000000", width=8, relief=ButRelief)
23617 root.style.configure("RConn.TButton", background=ButtonRed, foreground="#000000", width=5, relief=ButRelief)
23618 root.style.configure("GConn.TButton", background=ButtonGreen, foreground="#000000", width=5, relief=ButRelief)
23619 root.style.configure("Rtrace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=RAISED)
23620 root.style.configure("Strace1.TButton", background=COLORtrace1, foreground="#000000", width=7, relief=SUNKEN)
23621 root.style.configure("Ctrace1.TButton", background=COLORtrace1, foreground="#000000", relief=ButRelief)
23622 root.style.configure("Rtrace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=RAISED)
23623 root.style.configure("Strace2.TButton", background=COLORtrace2, foreground="#000000", width=7, relief=SUNKEN)
23624 root.style.configure("Ctrace2.TButton", background=COLORtrace2, foreground="#000000", relief=ButRelief)
23625 root.style.configure("Rtrace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=RAISED)
23626 root.style.configure("Strace3.TButton", background=COLORtrace3, foreground="#000000", width=7, relief=SUNKEN)
23627 root.style.configure("Ctrace3.TButton", background=COLORtrace3, foreground="#000000", relief=ButRelief)
23628 root.style.configure("Rtrace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=RAISED)
23629 root.style.configure("Strace4.TButton", background=COLORtrace4, foreground="#000000", width=7, relief=SUNKEN)
23630 root.style.configure("Ctrace4.TButton", background=COLORtrace4, foreground="#000000", relief=ButRelief)
23631 root.style.configure("Rtrace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=RAISED)
23632 root.style.configure("Strace6.TButton", background=COLORtrace6, foreground="#000000", width=7, relief=SUNKEN)
23633 root.style.configure("Rtrace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=RAISED)
23634 root.style.configure("Strace7.TButton", background=COLORtrace7, foreground="#000000", width=7, relief=SUNKEN)
23635 root.style.configure("RGray.TButton", background="#808080", width=7, relief=RAISED)
23636 root.style.configure("SGray.TButton", background="#808080", width=7, relief=SUNKEN)
23637 #
23638 root.style.configure("A10T5.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR5, font=('Arial', 10, 'bold'))
23639 root.style.configure("A10T5.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23640 root.style.configure("A10T6.TLabelframe.Label", background=FrameBG, foreground=COLORtrace6, font=('Arial', 10, 'bold'))
23641 root.style.configure("A10T6.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23642 root.style.configure("A10T7.TLabelframe.Label", background=FrameBG, foreground=COLORtrace7, font=('Arial', 10, 'bold'))
23643 root.style.configure("A10T7.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23644 #
23645 root.style.configure("A10R1.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR1, font=('Arial', 10, 'bold'))
23646 root.style.configure("A10R1.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23647 root.style.configure("A10R2.TLabelframe.Label", background=FrameBG, foreground=COLORtraceR2, font=('Arial', 10, 'bold'))
23648 root.style.configure("A10R2.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23649 root.style.configure("A10.TLabelframe.Label", background=FrameBG, font=('Arial', 10, 'bold'))
23650 root.style.configure("A10.TLabelframe", borderwidth=BorderSize, relief=FrameRefief)
23651 root.style.configure("A10B.TLabel", foreground=ButtonText, font="Arial 10 bold") # Black text
23652 root.style.configure("A10R.TLabel", foreground=ButtonRed, font="Arial 10 bold") # Red text
23653 root.style.configure("A10G.TLabel", foreground=ButtonGreen, font="Arial 10 bold") # Red text
23654 root.style.configure("A12B.TLabel", foreground=ButtonText, font="Arial 12 bold") # Black text
23655 root.style.configure("A16B.TLabel", foreground=ButtonText, font="Arial 16 bold") # Black text
23656 root.style.configure("Stop.TRadiobutton", background=ButtonRed, indicatorcolor=FrameBG)
23657 root.style.configure("Run.TRadiobutton", background=ButtonGreen, indicatorcolor=FrameBG)
23658 root.style.configure("Disab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonRed)
23659 root.style.configure("Enab.TCheckbutton", foreground=ButtonText, background=FrameBG, indicatorcolor=ButtonGreen)
23660 root.style.configure("Strace1.TCheckbutton", background=COLORtrace1, foreground="#000000", indicatorcolor="#ffffff")
23661 root.style.configure("Strace2.TCheckbutton", background=COLORtrace2, foreground="#000000", indicatorcolor="#ffffff")
23662 root.style.configure("Strace3.TCheckbutton", background=COLORtrace3, foreground="#000000", indicatorcolor="#ffffff")
23663 root.style.configure("Strace4.TCheckbutton", background=COLORtrace4, foreground="#000000", indicatorcolor="#ffffff")
23664 root.style.configure("Strace6.TCheckbutton", background=COLORtrace6, foreground="#000000", indicatorcolor="#ffffff")
23665 root.style.configure("Strace7.TCheckbutton", background=COLORtrace7, foreground="#000000", indicatorcolor="#ffffff")
23666 root.style.configure("WPhase.TRadiobutton", width=5, foreground="#000000", background="white", indicatorcolor=("red", "green"))
23667 root.style.configure("GPhase.TRadiobutton", width=5, foreground="#000000", background="gray", indicatorcolor=("red", "green"))
23668 # Create frames
23669 frame2r = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23670 frame2r.pack(side=RIGHT, fill=BOTH, expand=NO)
23671 
23672 frame1 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23673 frame1.pack(side=TOP, fill=BOTH, expand=NO)
23674 
23675 frame2 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23676 frame2.pack(side=TOP, fill=BOTH, expand=YES)
23677 
23678 frame3 = Frame(root, borderwidth=BorderSize, relief=FrameRefief)
23679 frame3.pack(side=TOP, fill=BOTH, expand=NO)
23680 # create a pulldown menu
23681 # Trigger signals
23682 Triggermenu = Menubutton(frame1, text="Trigger", style="W7.TButton")
23683 Triggermenu.menu = Menu(Triggermenu, tearoff = 0 )
23684 Triggermenu["menu"] = Triggermenu.menu
23685 Triggermenu.menu.add_radiobutton(label='None', variable=TgInput, value=0)
23686 Triggermenu.menu.add_radiobutton(label='CA-V', variable=TgInput, value=1)
23687 Triggermenu.menu.add_radiobutton(label='CA-I', variable=TgInput, value=2)
23688 Triggermenu.menu.add_radiobutton(label='CB-V', variable=TgInput, value=3)
23689 Triggermenu.menu.add_radiobutton(label='CB-I', variable=TgInput, value=4)
23690 Triggermenu.menu.add_radiobutton(label='CA-V or CB-V', variable=TgInput, value=5)
23691 # Triggermenu.menu.add_radiobutton(label='Alternate A/B', variable=TgInput, value=6)
23692 Triggermenu.menu.add_checkbutton(label='Auto Level', variable=AutoLevel)
23693 Triggermenu.menu.add_checkbutton(label='Low Pass Filter', variable=LPFTrigger)
23694 Triggermenu.menu.add_checkbutton(label='Manual Trgger', variable=ManualTrigger)
23695 Triggermenu.menu.add_checkbutton(label='SingleShot', variable=SingleShot)
23696 Triggermenu.pack(side=LEFT)
23697 #
23698 Edgemenu = Menubutton(frame1, text="Edge", style="W5.TButton")
23699 Edgemenu.menu = Menu(Edgemenu, tearoff = 0 )
23700 Edgemenu["menu"] = Edgemenu.menu
23701 Edgemenu.menu.add_radiobutton(label='Rising (+)', variable=TgEdge, value=0)
23702 Edgemenu.menu.add_radiobutton(label='Falling (-)', variable=TgEdge, value=1)
23703 Edgemenu.pack(side=LEFT)
23704 #
23705 tlab = Label(frame1, text="Trig Level")
23706 tlab.pack(side=LEFT)
23707 TRIGGERentry = Entry(frame1, width=5, cursor='double_arrow')
23708 TRIGGERentry.bind('<MouseWheel>', onTextScroll)
23709 TRIGGERentry.bind("<Button-4>", onTextScroll)# with Linux OS
23710 TRIGGERentry.bind("<Button-5>", onTextScroll)
23711 TRIGGERentry.bind("<Return>", BTriglevel)
23712 TRIGGERentry.bind('<Key>', onTextKey)
23713 TRIGGERentry.pack(side=LEFT)
23714 TRIGGERentry.delete(0,"end")
23715 TRIGGERentry.insert(0,0.0)
23716 #
23717 tgb = Button(frame1, text="50%", style="W4.TButton", command=BTrigger50p)
23718 tgb.pack(side=LEFT)
23719 #
23720 hldlab = Button(frame1, text="Hold Off", style="W8.TButton", command=IncHoldOff)
23721 hldlab.pack(side=LEFT)
23722 HoldOffentry = Entry(frame1, width=4, cursor='double_arrow')
23723 HoldOffentry.bind('<MouseWheel>', onTextScroll)
23724 HoldOffentry.bind("<Button-4>", onTextScroll)# with Linux OS
23725 HoldOffentry.bind("<Button-5>", onTextScroll)
23726 HoldOffentry.bind("<Return>", BHoldOff)
23727 HoldOffentry.bind('<Key>', onTextKey)
23728 HoldOffentry.pack(side=LEFT)
23729 HoldOffentry.delete(0,"end")
23730 HoldOffentry.insert(0,0.0)
23731 #
23732 hozlab = Button(frame1, text="Horz Pos", style="W8.TButton", command=SetTriggerPoss)
23733 hozlab.pack(side=LEFT)
23734 HozPossentry = Entry(frame1, width=4, cursor='double_arrow')
23735 HozPossentry.bind('<MouseWheel>', onTextScroll)
23736 HozPossentry.bind("<Button-4>", onTextScroll)# with Linux OS
23737 HozPossentry.bind("<Button-5>", onTextScroll)
23738 HozPossentry.bind("<Return>", BHozPoss)
23739 HozPossentry.bind('<Key>', onTextKey)
23740 HozPossentry.pack(side=LEFT)
23741 HozPossentry.delete(0,"end")
23742 HozPossentry.insert(0,0.0)
23743 #
23744 bexit = Button(frame1, text="Exit", style="W4.TButton", command=Bcloseexit)
23745 bexit.pack(side=RIGHT)
23746 bstop = Button(frame1, text="Stop", style="Stop.TButton", command=BStop)
23747 bstop.pack(side=RIGHT)
23748 brun = Button(frame1, text="Run", style="Run.TButton", command=BStart)
23749 brun.pack(side=RIGHT)
23750 PwrBt = Button(frame1, text="PWR-ON", style="Pwr.TButton", command=BPower)
23751 PwrBt.pack(side=RIGHT)
23752 # Curves Menu
23753 if EnableScopeOnly == 0:
23754  Showmenu = Menubutton(frame1, text="Curves", style="W7.TButton")
23755 else:
23756  Showmenu = Menubutton(frame1, text="Traces", style="W7.TButton")
23757 Showmenu.menu = Menu(Showmenu, tearoff = 0 )
23758 Showmenu["menu"] = Showmenu.menu
23759 Showmenu.menu.add_command(label="-Show Traces-", foreground="blue", command=donothing)
23760 Showmenu.menu.add_command(label="All", command=BShowCurvesAll)
23761 Showmenu.menu.add_command(label="None", command=BShowCurvesNone)
23762 Showmenu.menu.add_checkbutton(label='CA-V (1)', background=COLORtrace1, variable=ShowC1_V, command=TraceSelectADC_Mux)
23763 Showmenu.menu.add_checkbutton(label='CA-I (3)', background=COLORtrace3, variable=ShowC1_I, command=TraceSelectADC_Mux)
23764 Showmenu.menu.add_checkbutton(label='CB-V (2)', background=COLORtrace2, variable=ShowC2_V, command=TraceSelectADC_Mux)
23765 Showmenu.menu.add_checkbutton(label='CB-I (4)', background=COLORtrace4,variable=ShowC2_I, command=TraceSelectADC_Mux)
23766 Showmenu.menu.add_checkbutton(label='Math-X', background=COLORtrace6, variable=Show_MathX, command=UpdateTimeTrace)
23767 Showmenu.menu.add_checkbutton(label='Math-Y', background=COLORtrace7, variable=Show_MathY, command=UpdateTimeTrace)
23768 Showmenu.menu.add_command(label="-Auto Vert Center-", foreground="blue", command=donothing)
23769 Showmenu.menu.add_checkbutton(label='Center CA-V', variable=AutoCenterA)
23770 Showmenu.menu.add_checkbutton(label='Center CB-V', variable=AutoCenterB)
23771 Showmenu.menu.add_command(label="-Input HP Comp-", foreground="blue", command=donothing)
23772 Showmenu.menu.add_checkbutton(label='Comp CA-V', variable=CHA_RC_HP)
23773 Showmenu.menu.add_checkbutton(label='Comp CB-V', variable=CHB_RC_HP)
23774 if EnableHSsampling > 0:
23775  Showmenu.menu.add_checkbutton(label='Comp CA-I', variable=CHAI_RC_HP)
23776  Showmenu.menu.add_checkbutton(label='Comp CB-I', variable=CHBI_RC_HP)
23777 Showmenu.menu.add_separator()
23778 Showmenu.menu.add_checkbutton(label='RA-V', background=COLORtraceR1, variable=ShowRA_V, command=UpdateTimeTrace)
23779 Showmenu.menu.add_checkbutton(label='RA-I', background=COLORtraceR3, variable=ShowRA_I, command=UpdateTimeTrace)
23780 Showmenu.menu.add_checkbutton(label='RB-V', background=COLORtraceR2, variable=ShowRB_V, command=UpdateTimeTrace)
23781 Showmenu.menu.add_checkbutton(label='RB-I', background=COLORtraceR4, variable=ShowRB_I, command=UpdateTimeTrace)
23782 Showmenu.menu.add_checkbutton(label='RMath', background=COLORtraceR5, variable=ShowMath, command=UpdateTimeTrace)
23783 Showmenu.menu.add_separator()
23784 Showmenu.menu.add_checkbutton(label='T Cursor (t)', variable=ShowTCur, command=UpdateTimeTrace)
23785 Showmenu.menu.add_checkbutton(label='V Cursor (v)', variable=ShowVCur, command=UpdateTimeTrace)
23786 Showmenu.pack(side=RIGHT)
23787 #
23788 if ShowBallonHelp > 0:
23789  Triggermenu_tip = CreateToolTip(Triggermenu, 'Select trigger signal')
23790  Edgemenu_tip = CreateToolTip(Edgemenu, 'Select trigger edge')
23791  tgb_tip = CreateToolTip(tgb, 'Set trigger level to waveform mid point')
23792  hldlab_tip = CreateToolTip(hldlab, 'Increment Hold Off setting by one time division')
23793  hozlab_tip = CreateToolTip(hozlab, 'When triggering, set trigger point to center of screen')
23794  bexit_tip = CreateToolTip(bexit, 'Exit ALICE Desktop')
23795  bstop_tip = CreateToolTip(bstop, 'Stop acquiring data')
23796  brun_tip = CreateToolTip(brun, 'Start acquiring data')
23797  pwrbt_tip = CreateToolTip(PwrBt, 'Toggle ext power supply')
23798  Showmenu_tip = CreateToolTip(Showmenu, 'Select which traces to display')
23799 
23800 # Sampling controls Widgets
23801 if EnableHSsampling > 0:
23802  fminlab2 = Label(frame1, text="KHz")
23803  fminlab2.pack(side=RIGHT)
23804  FminEntry = Entry(frame1, width=6, cursor='double_arrow')
23805  FminEntry.bind('<MouseWheel>', onFminScroll)
23806  FminEntry.bind("<Button-4>", onFminScroll)# with Linux OS
23807  FminEntry.bind("<Button-5>", onFminScroll)
23808  FminEntry.bind("<Return>", SetAD9833)
23809  FminEntry.pack(side=RIGHT)
23810  FminEntry.delete(0,"end")
23811  FminEntry.insert(0,25)
23812  fminlab = Button(frame1, text="Fmin", style="W5.TButton", command=BSetFmin)
23813  fminlab.pack(side=RIGHT)
23814  #
23815  HtMulEntry = Entry(frame1, width=4, cursor='double_arrow')
23816  HtMulEntry.bind('<MouseWheel>', onMulXScroll)
23817  HtMulEntry.bind("<Button-4>", onMulXScroll)# with Linux OS
23818  HtMulEntry.bind("<Button-5>", onMulXScroll)
23819  HtMulEntry.bind("<Return>", SetAD9833)
23820  HtMulEntry.pack(side=RIGHT)
23821  HtMulEntry.delete(0,"end")
23822  HtMulEntry.insert(0,1)
23823  mulxlab = Label( frame1, text = "Mul X")
23824  mulxlab.pack(side=RIGHT)
23825 else:
23826  RollBt = Button(frame1, text="Roll-Off", style="RollOff.TButton", command=BRoll)
23827  RollBt.pack(side=RIGHT)
23828 #
23829 # Time per Div
23830 TMsb = Spinbox(frame1, width=5, values= TMpdiv, cursor='double_arrow', command=BTime)
23831 TMsb.bind('<MouseWheel>', onSpinBoxScroll)
23832 TMsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
23833 TMsb.bind("<Button-5>", onSpinBoxScroll)
23834 TMsb.pack(side=RIGHT)
23835 TMsb.delete(0,"end")
23836 TMsb.insert(0,0.5)
23837 TMlab = Label(frame1, text="Time mS/Div")
23838 TMlab.pack(side=RIGHT)
23839 #
23840 ca = Canvas(frame2, width=CANVASwidth, height=CANVASheight, background=COLORcanvas, cursor='cross')
23841 # add mouse left and right button click to canvas
23842 ca.bind('<Configure>', CAresize)
23843 ca.bind('<1>', onCanvasClickLeft)
23844 ca.bind('<3>', onCanvasClickRight)
23845 ca.bind("<Motion>",onCanvasMouse_xy)
23846 ca.bind("<Up>", onCanvasUpArrow) # DoNothing)
23847 ca.bind("<Down>", onCanvasDownArrow)
23848 ca.bind("<Left>", onCanvasLeftArrow)
23849 ca.bind("<Right>", onCanvasRightArrow)
23850 ca.bind("<space>", onCanvasSpaceBar)
23851 ca.bind("1", onCanvasOne)
23852 ca.bind("2", onCanvasTwo)
23853 ca.bind("3", onCanvasThree)
23854 ca.bind("4", onCanvasFour)
23855 ca.bind("5", onCanvasFive)
23856 ca.bind("6", onCanvasSix)
23857 ca.bind("7", onCanvasSeven)
23858 ca.bind("8", onCanvasEight)
23859 ca.bind("9", onCanvasNine)
23860 ca.bind("0", onCanvasZero)
23861 ca.bind("a", onCanvasAverage)
23862 ca.bind("t", onCanvasShowTcur)
23863 ca.bind("v", onCanvasShowVcur)
23864 ca.bind("s", onCanvasSnap)
23865 ca.bind("+", onCanvasTrising)
23866 ca.bind("-", onCanvasTfalling)
23867 ca.bind('<MouseWheel>', onCanvasClickScroll)
23868 ca.bind("<Button-4>", onCanvasClickScroll)# with Linux OS
23869 ca.bind("<Button-5>", onCanvasClickScroll)
23870 ca.pack(side=TOP, fill=BOTH, expand=YES)
23871 MouseWidget = ca
23872 # right side menu buttons
23873 dropmenu = Frame( frame2r )
23874 dropmenu.pack(side=TOP)
23875 bcon = Button(dropmenu, text="Recon", style="RConn.TButton", command=ConnectDevice)
23876 bcon.pack(side=LEFT, anchor=W)
23877 # File menu
23878 Filemenu = Menubutton(dropmenu, text="File", style="W4.TButton")
23879 Filemenu.menu = Menu(Filemenu, tearoff = 0 )
23880 Filemenu["menu"] = Filemenu.menu
23881 Filemenu.menu.add_command(label="Save Config", command=BSaveConfigTime)
23882 Filemenu.menu.add_command(label="Load Config", command=BLoadConfigTime)
23883 Filemenu.menu.add_command(label="Run Script", command=RunScript)
23884 Filemenu.menu.add_command(label="Save Adj", command=BSaveCal)
23885 Filemenu.menu.add_command(label="Load Adj", command=BLoadCal)
23886 Filemenu.menu.add_command(label="Save Screen", command=BSaveScreen)
23887 Filemenu.menu.add_command(label="Save To CSV", command=BSaveData)
23888 Filemenu.menu.add_command(label="Load From CSV", command=BReadData)
23889 Filemenu.menu.add_command(label="Save PWL Data", command=BSaveChannelData)
23890 Filemenu.menu.add_command(label="Help", command=BHelp)
23891 Filemenu.menu.add_command(label="About", command=BAbout)
23892 Filemenu.pack(side=LEFT, anchor=W)
23893 # Options Menu
23894 Optionmenu = Menubutton(dropmenu, text="Options", style="W7.TButton")
23895 Optionmenu.menu = Menu(Optionmenu, tearoff = 0 )
23896 Optionmenu["menu"] = Optionmenu.menu
23897 Optionmenu.menu.add_command(label='Change Settings', command=MakeSettingsMenu)
23898 Optionmenu.menu.add_command(label='Set Sample Rate', command=MakeSampleRateMenu) # SetSampleRate)
23899 Optionmenu.menu.add_checkbutton(label='Smooth', variable=SmoothCurves, command=UpdateTimeTrace)
23900 Optionmenu.menu.add_checkbutton(label='Z-O-Hold', variable=ZOHold, command=UpdateTimeTrace)
23901 Optionmenu.menu.add_checkbutton(label='Decimate', variable=DecimateOption)
23902 Optionmenu.menu.add_checkbutton(label='Gated Meas', variable=MeasGateStatus)
23903 Optionmenu.menu.add_checkbutton(label='Trace Avg (a)', variable=TRACEmodeTime)
23904 Optionmenu.menu.add_checkbutton(label='Persistance', variable=ScreenTrefresh)
23905 Optionmenu.menu.add_command(label='Set Marker Location', command=BSetMarkerLocation)
23906 Optionmenu.menu.add_command(label='Change Plot Label', command=BUserCustomPlotText)
23907 Optionmenu.menu.add_command(label="SnapShot (s)", command=BSnapShot)
23908 Optionmenu.menu.add_radiobutton(label='Black BG', variable=ColorMode, value=0, command=BgColor)
23909 Optionmenu.menu.add_radiobutton(label='White BG', variable=ColorMode, value=1, command=BgColor)
23910 Optionmenu.menu.add_command(label="Run Self Cal", command=SelfCalibration)
23911 if EnableScopeOnly != 0:
23912  Optionmenu.menu.add_command(label="Open Instruments", command=OpenOtherTools)
23913 if AllowFlashFirmware == 1:
23914  Optionmenu.menu.add_command(label="Save Cal Settings", command=Save_Cal_file)
23915  Optionmenu.menu.add_command(label="Update Firmware", command=UpdateFirmware)
23916 Optionmenu.pack(side=LEFT, anchor=W)
23917 #
23918 dropmenu2 = Frame( frame2r )
23919 dropmenu2.pack(side=TOP)
23920 # Open Math trace menu
23921 mathbt = Button(dropmenu2, text="Math", style="W4.TButton", command = NewEnterMathControls)
23922 mathbt.pack(side=RIGHT, anchor=W)
23923 # Measurments menu
23924 measlab = Label(dropmenu2, text="Meas")
23925 measlab.pack(side=LEFT, anchor=W)
23926 MeasmenuA = Menubutton(dropmenu2, text="CA", style="W3.TButton")
23927 MeasmenuA.menu = Menu(MeasmenuA, tearoff = 0 )
23928 MeasmenuA["menu"] = MeasmenuA.menu
23929 MeasmenuA.menu.add_command(label="-CA-V-", foreground="blue", command=donothing)
23930 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCV1)
23931 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinV1)
23932 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxV1)
23933 MeasmenuA.menu.add_checkbutton(label='Base', variable=MeasBaseV1)
23934 MeasmenuA.menu.add_checkbutton(label='Top', variable=MeasTopV1)
23935 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidV1)
23936 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPV1)
23937 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSV1)
23938 MeasmenuA.menu.add_checkbutton(label='CA-CB', variable=MeasDiffAB)
23939 MeasmenuA.menu.add_checkbutton(label='CA-CB RMS', variable=MeasRMSVA_B)
23940 MeasmenuA.menu.add_checkbutton(label='User', variable=MeasUserA, command=BUserAMeas)
23941 #MeasmenuA.menu.add_separator()
23942 MeasmenuA.menu.add_command(label="-CA-I-", foreground="blue", command=donothing)
23943 MeasmenuA.menu.add_checkbutton(label='Avg', variable=MeasDCI1)
23944 MeasmenuA.menu.add_checkbutton(label='Min', variable=MeasMinI1)
23945 MeasmenuA.menu.add_checkbutton(label='Max', variable=MeasMaxI1)
23946 MeasmenuA.menu.add_checkbutton(label='Mid', variable=MeasMidI1)
23947 MeasmenuA.menu.add_checkbutton(label='P-P', variable=MeasPPI1)
23948 MeasmenuA.menu.add_checkbutton(label='RMS', variable=MeasRMSI1)
23949 #MeasmenuA.menu.add_separator()
23950 MeasmenuA.menu.add_command(label="-CA-Time-", foreground="blue", command=donothing)
23951 MeasmenuA.menu.add_checkbutton(label='H-Width', variable=MeasAHW)
23952 MeasmenuA.menu.add_checkbutton(label='L-Width', variable=MeasALW)
23953 MeasmenuA.menu.add_checkbutton(label='DutyCyle', variable=MeasADCy)
23954 MeasmenuA.menu.add_checkbutton(label='Period', variable=MeasAPER)
23955 MeasmenuA.menu.add_checkbutton(label='Freq', variable=MeasAFREQ)
23956 MeasmenuA.menu.add_checkbutton(label='A-B Phase', variable=MeasPhase)
23957 #
23958 MeasmenuA.pack(side=LEFT)
23959 #
23960 MeasmenuB = Menubutton(dropmenu2, text="CB", style="W3.TButton")
23961 MeasmenuB.menu = Menu(MeasmenuB, tearoff = 0 )
23962 MeasmenuB["menu"] = MeasmenuB.menu
23963 MeasmenuB.menu.add_command(label="-CB-V-", foreground="blue", command=donothing)
23964 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCV2)
23965 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinV2)
23966 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxV2)
23967 MeasmenuB.menu.add_checkbutton(label='Base', variable=MeasBaseV2)
23968 MeasmenuB.menu.add_checkbutton(label='Top', variable=MeasTopV2)
23969 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidV2)
23970 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPV2)
23971 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSV2)
23972 MeasmenuB.menu.add_checkbutton(label='CB-CA', variable=MeasDiffBA)
23973 MeasmenuB.menu.add_checkbutton(label='User', variable=MeasUserB, command=BUserBMeas)
23974 #MeasmenuB.menu.add_separator()
23975 MeasmenuB.menu.add_command(label="-CB-I-", foreground="blue", command=donothing)
23976 MeasmenuB.menu.add_checkbutton(label='Avg', variable=MeasDCI2)
23977 MeasmenuB.menu.add_checkbutton(label='Min', variable=MeasMinI2)
23978 MeasmenuB.menu.add_checkbutton(label='Max', variable=MeasMaxI2)
23979 MeasmenuB.menu.add_checkbutton(label='Mid', variable=MeasMidI2)
23980 MeasmenuB.menu.add_checkbutton(label='P-P', variable=MeasPPI2)
23981 MeasmenuB.menu.add_checkbutton(label='RMS', variable=MeasRMSI2)
23982 #MeasmenuB.menu.add_separator()
23983 MeasmenuB.menu.add_command(label="-CB-Time-", foreground="blue", command=donothing)
23984 MeasmenuB.menu.add_checkbutton(label='H-Width', variable=MeasBHW)
23985 MeasmenuB.menu.add_checkbutton(label='L-Width', variable=MeasBLW)
23986 MeasmenuB.menu.add_checkbutton(label='DutyCyle', variable=MeasBDCy)
23987 MeasmenuB.menu.add_checkbutton(label='Period', variable=MeasBPER)
23988 MeasmenuB.menu.add_checkbutton(label='Freq', variable=MeasBFREQ)
23989 MeasmenuB.menu.add_checkbutton(label='B-A Delay', variable=MeasDelay)
23990 MeasmenuB.pack(side=LEFT)
23991 if ShowBallonHelp > 0:
23992  math_tip = CreateToolTip(mathbt, 'Open Math window')
23993  options_tip = CreateToolTip(Optionmenu, 'Select Optional Settings')
23994  file_tip = CreateToolTip(Filemenu, 'Select File operations')
23995 #
23996 DigScreenStatus = IntVar(0)
23997 DigScreenStatus.set(0)
23998 #
23999 if EnableScopeOnly == 0:
24000  BuildAWGScreen = Button(frame2r, text="AWG Window", style="W16.TButton", command=MakeAWGWindow)
24001  BuildAWGScreen.pack(side=TOP)
24002  # Mode selector
24003  timebtn = Frame( frame2r )
24004  timebtn.pack(side=TOP)
24005  ckb1 = Checkbutton(timebtn, text="Enab", style="Disab.TCheckbutton", variable=TimeDisp, command=TimeCheckBox)
24006  ckb1.pack(side=LEFT)
24007  timelab = Label(timebtn, text="Time Plot")
24008  timelab.pack(side=LEFT)
24009  if EnableXYPlotter > 0:
24010  xybtn = Frame( frame2r )
24011  xybtn.pack(side=TOP)
24012  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
24013  ckb2.pack(side=LEFT)
24014  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
24015  BuildXYScreen.pack(side=TOP)
24016  #
24017  if EnablePhaseAnalizer > 0:
24018  phasebtn = Frame( frame2r )
24019  phasebtn.pack(side=TOP)
24020  phckb = Checkbutton(phasebtn, text="Enab", style="Disab.TCheckbutton", variable=PhADisp, command=PhACheckBox)
24021  phckb.pack(side=LEFT)
24022  BuildPhAScreen = Button(phasebtn, text="Phasor Plot", style="W11.TButton", command=MakePhAWindow)
24023  BuildPhAScreen.pack(side=LEFT)
24024  #
24025  if EnableSpectrumAnalizer > 0:
24026  freqbtn = Frame( frame2r )
24027  freqbtn.pack(side=TOP)
24028  ckb3 = Checkbutton(freqbtn, text="Enab", style="Disab.TCheckbutton", variable=FreqDisp, command=FreqCheckBox)
24029  ckb3.pack(side=LEFT)
24030  BuildSpectrumScreen = Button(freqbtn, text="Spectrum Plot", style="W11.TButton", command=MakeSpectrumWindow)
24031  BuildSpectrumScreen.pack(side=LEFT)
24032  #
24033  if EnableBodePlotter > 0:
24034  bodebtn = Frame( frame2r )
24035  bodebtn.pack(side=TOP)
24036  ckb5 = Checkbutton(bodebtn, text="Enab", style="Disab.TCheckbutton", variable=BodeDisp, command=BodeCheckBox)
24037  ckb5.pack(side=LEFT)
24038  BuildBodeScreen = Button(bodebtn, text="Bode Plot", style="W11.TButton", command=MakeBodeWindow)
24039  BuildBodeScreen.pack(side=LEFT)
24040  #
24041  if EnableImpedanceAnalizer > 0:
24042  impdbtn = Frame( frame2r )
24043  impdbtn.pack(side=TOP)
24044  ckb4 = Checkbutton(impdbtn, text="Enab", style="Disab.TCheckbutton", variable=IADisp, command=IACheckBox)
24045  ckb4.pack(side=LEFT)
24046  BuildIAScreen = Button(impdbtn, text="Impedance", style="W11.TButton", command=MakeIAWindow)
24047  BuildIAScreen.pack(side=LEFT)
24048  #
24049  if EnableOhmMeter > 0:
24050  dcohmbtn = Frame( frame2r )
24051  dcohmbtn.pack(side=TOP)
24052  ckb6 = Checkbutton(dcohmbtn, text="Enab", style="Disab.TCheckbutton", variable=OhmDisp, command=OhmCheckBox)
24053  ckb6.pack(side=LEFT)
24054  BuildOhmScreen = Button(dcohmbtn, text="Ohmmeter", style="W11.TButton", command=MakeOhmWindow)
24055  BuildOhmScreen.pack(side=LEFT)
24056  #
24057  if ShowTraceControls > 0:
24058  Labelfonttext = "Arial " + str(FontSize) + " bold"
24059  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
24060  tracelab.pack(side=TOP)
24061  trctrla = Frame( frame2r )
24062  trctrla.pack(side=TOP)
24063  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
24064  ckbt1.pack(side=LEFT,fill=X)
24065  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
24066  ckbt2.pack(side=LEFT,fill=X)
24067  trctrlb = Frame( frame2r )
24068  trctrlb.pack(side=TOP)
24069  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
24070  ckbt3.pack(side=LEFT,fill=X)
24071  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
24072  ckbt4.pack(side=LEFT,fill=X)
24073 
24074  if ShowBallonHelp > 0:
24075  try:
24076  BuildAWGScreen_tip = CreateToolTip(BuildAWGScreen, 'Surface AWG Controls window')
24077  except:
24078  donothing()
24079  try:
24080  BuildXYScreen_tip = CreateToolTip(BuildXYScreen, 'Open X vs Y plot window')
24081  except:
24082  donothing()
24083  try:
24084  BuildPhAScreen_tip = CreateToolTip(BuildPhAScreen, 'Open Phase Analyzer window')
24085  except:
24086  donothing()
24087  try:
24088  BuildSpectrumScreen_tip = CreateToolTip(BuildSpectrumScreen, 'Open Spectrum Analyzer window')
24089  except:
24090  donothing()
24091  try:
24092  BuildBodeScreen_tip = CreateToolTip(BuildBodeScreen, 'Open Bode plot window')
24093  except:
24094  donothing()
24095  try:
24096  BuildIAScreen_tip = CreateToolTip(BuildIAScreen, 'Open Impedance Analyzer window')
24097  except:
24098  donothing()
24099  try:
24100  BuildOhmScreen_tip = CreateToolTip(BuildOhmScreen, 'Open DC Ohmmeter window')
24101  except:
24102  donothing()
24103  # Digital Input / Output Option screens
24104  if EnableDigIO > 0:
24105  BuildDigScreen = Button(frame2r, text="Digital I/O Screen", style="W17.TButton", command=MakeDigScreen)
24106  BuildDigScreen.pack(side=TOP)
24107  # Optional plugin tools
24108  if EnablePIODACMode > 0:
24109  BuildDacScreen = Button(frame2r, text="PIO-DAC Screen", style="W17.TButton", command=MakeDacScreen)
24110  BuildDacScreen.pack(side=TOP)
24111  if EnableMuxMode > 0:
24112  BuildMuxScreen = Button(frame2r, text="Analog In Mux Screen", style="W17.TButton", command=MakeMuxModeWindow)
24113  BuildMuxScreen.pack(side=TOP)
24114  if EnableMinigenMode > 0:
24115  BuildMinigenScreen = Button(frame2r, text="AD983x DDS Screen", style="W17.TButton", command=MakeMinigenWindow)
24116  BuildMinigenScreen.pack(side=TOP)
24117  if EnablePmodDA1Mode > 0:
24118  BuildDA1Screen = Button(frame2r, text="PMOD DA1 Screen", style="W17.TButton", command=MakeDA1Window)
24119  BuildDA1Screen.pack(side=TOP)
24120  if EnableDigPotMode >0:
24121  BuildDigPotScreen = Button(frame2r, text="Dig Pot Screen", style="W17.TButton", command=MakeDigPotWindow)
24122  BuildDigPotScreen.pack(side=TOP)
24123  if EnableGenericSerialMode >0:
24124  GenericSerialScreen = Button(frame2r, text="Generic Serial Output", style="W17.TButton", command=MakeGenericSerialWindow)
24125  GenericSerialScreen.pack(side=TOP)
24126  if EnableAD5626SerialMode >0:
24127  AD5626SerialScreen = Button(frame2r, text="AD5626 Output", style="W17.TButton", command=MakeAD5626Window)
24128  AD5626SerialScreen.pack(side=TOP)
24129  if EnableDigitalFilter >0:
24130  DigFiltScreen = Button(frame2r, text="Digital Filter", style="W17.TButton", command=MakeDigFiltWindow)
24131  DigFiltScreen.pack(side=TOP)
24132  if EnableCommandInterface > 0:
24133  CommandLineScreen = Button(frame2r, text="Command Interface", style="W17.TButton", command=MakeCommandScreen)
24134  CommandLineScreen.pack(side=TOP)
24135  if EnableMeasureScreen > 0:
24136  MeasureScreen = Button(frame2r, text="Measure Screen", style="W17.TButton", command=MakeMeasureScreen)
24137  MeasureScreen.pack(side=TOP)
24138  if EnableETSScreen > 0:
24139  ETSScreen = Button(frame2r, text="ETS Controls", style="W17.TButton", command=MakeETSWindow)
24140  ETSScreen.pack(side=TOP)
24141 else:
24142 # Mode selector
24143  if EnableXYPlotter > 0:
24144  xybtn = Frame( frame2r )
24145  xybtn.pack(side=TOP)
24146  ckb2 = Checkbutton(xybtn, text="Enab", style="Disab.TCheckbutton", variable=XYDisp, command=XYCheckBox)
24147  ckb2.pack(side=LEFT)
24148  BuildXYScreen = Button(xybtn, text="X-Y Plot", style="W11.TButton", command=MakeXYWindow)
24149  BuildXYScreen.pack(side=TOP)
24150  #
24151  if ShowTraceControls > 0:
24152  Labelfonttext = "Arial " + str(FontSize) + " bold"
24153  tracelab = Label(frame2r, text="Traces", font= Labelfonttext)
24154  tracelab.pack(side=TOP)
24155  trctrla = Frame( frame2r )
24156  trctrla.pack(side=TOP)
24157  ckbt1 = Checkbutton(trctrla, text='CA-V (1)', style="Strace1.TCheckbutton", variable=ShowC1_V, command=TraceSelectADC_Mux)
24158  ckbt1.pack(side=LEFT,fill=X)
24159  ckbt2 = Checkbutton(trctrla, text='CA-I (3)', style="Strace3.TCheckbutton", variable=ShowC1_I, command=TraceSelectADC_Mux)
24160  ckbt2.pack(side=LEFT,fill=X)
24161  trctrlb = Frame( frame2r )
24162  trctrlb.pack(side=TOP)
24163  ckbt3 = Checkbutton(trctrlb, text='CB-V (2)', style="Strace2.TCheckbutton", variable=ShowC2_V, command=TraceSelectADC_Mux)
24164  ckbt3.pack(side=LEFT,fill=X)
24165  ckbt4 = Checkbutton(trctrlb, text='CB-I (4)', style="Strace4.TCheckbutton", variable=ShowC2_I, command=TraceSelectADC_Mux)
24166  ckbt4.pack(side=LEFT,fill=X)
24167  #
24168  awg1eb = Frame( frame2r )
24169  awg1eb.pack(side=TOP)
24170  ModeAMenu = Menubutton(awg1eb, text="Mode", width=5, style="Ctrace1.TButton")#, style="W5.TButton")
24171  ModeAMenu.menu = Menu(ModeAMenu, tearoff = 0 )
24172  ModeAMenu["menu"] = ModeAMenu.menu
24173  ModeAMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
24174  ModeAMenu.menu.add_radiobutton(label="SVMI", variable=AWGAMode, value=0, command=BAWGAModeLabel)
24175  ModeAMenu.menu.add_radiobutton(label="SIMV", variable=AWGAMode, value=1, command=BAWGAModeLabel)
24176  ModeAMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGAMode, value=2, command=BAWGAModeLabel)
24177  ModeAMenu.menu.add_checkbutton(label="Split I/O", variable=AWGAIOMode, command=BAWGAModeLabel)
24178  ModeAMenu.menu.add_separator()
24179  ModeAMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
24180  ModeAMenu.menu.add_radiobutton(label="Open", variable=AWGATerm, value=0, command=UpdateAwgCont)
24181  ModeAMenu.menu.add_radiobutton(label="To GND", variable=AWGATerm, value=1, command=UpdateAwgCont)
24182  ModeAMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGATerm, value=2, command=UpdateAwgCont)
24183  ModeAMenu.pack(side=LEFT, anchor=W)
24184  ShapeAMenu = Menubutton(awg1eb, text="Shape", width=6, style="Ctrace1.TButton")#, style="W6.TButton")
24185  ShapeAMenu.menu = Menu(ShapeAMenu, tearoff = 0 )
24186  ShapeAMenu["menu"] = ShapeAMenu.menu
24187  ShapeAMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
24188  ShapeAMenu.menu.add_radiobutton(label="DC", variable=AWGAShape, value=0, command=ReMakeAWGwaves)
24189  ShapeAMenu.menu.add_radiobutton(label="Sine", variable=AWGAShape, value=18, command=ReMakeAWGwaves)
24190  ShapeAMenu.menu.add_radiobutton(label="Triangle", variable=AWGAShape, value=2, command=ReMakeAWGwaves)
24191  ShapeAMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGAShape, value=3, command=ReMakeAWGwaves)
24192  ShapeAMenu.menu.add_radiobutton(label="Square", variable=AWGAShape, value=4, command=ReMakeAWGwaves)
24193  ShapeAMenu.menu.add_radiobutton(label="StairStep", variable=AWGAShape, value=5, command=ReMakeAWGwaves)
24194  if AWGShowAdvanced.get() > 0:
24195  ShapeAMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
24196  ShapeAMenu.menu.add_radiobutton(label="Impulse", variable=AWGAShape, value=9, command=ReMakeAWGwaves)
24197  ShapeAMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGAShape, value=11, command=ReMakeAWGwaves)
24198  ShapeAMenu.menu.add_radiobutton(label="Pulse", variable=AWGAShape, value=20, command=ReMakeAWGwaves)
24199  ShapeAMenu.menu.add_radiobutton(label="Ramp", variable=AWGAShape, value=16, command=ReMakeAWGwaves)
24200  ShapeAMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGAShape, value=15, command=ReMakeAWGwaves)
24201  ShapeAMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGAShape, value=12, command=ReMakeAWGwaves)
24202  ShapeAMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGAShape, value=14, command=AWGAMakeFourier)
24203  ShapeAMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGAShape, value=19, command=ReMakeAWGwaves)
24204  ShapeAMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGAShape, value=17, command=ReMakeAWGwaves)
24205  ShapeAMenu.menu.add_radiobutton(label="FM Sine", variable=AWGAShape, value=21, command=AWGAMakeFMSine)
24206  ShapeAMenu.menu.add_radiobutton(label="AM Sine", variable=AWGAShape, value=22, command=AWGAMakeAMSine)
24207  ShapeAMenu.menu.add_radiobutton(label="UU Noise", variable=AWGAShape, value=7, command=ReMakeAWGwaves)
24208  ShapeAMenu.menu.add_radiobutton(label="UG Noise", variable=AWGAShape, value=8, command=ReMakeAWGwaves)
24209  else:
24210  ShapeAMenu.menu.add_separator()
24211  ShapeAMenu.menu.add_radiobutton(label="Math", variable=AWGAShape, value=10, command=AWGAMakeMath)
24212  ShapeAMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGAShape, value=6, command=AWGAReadFile)
24213  ShapeAMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGAShape, value=13, command=AWGAReadWAV)
24214  ShapeAMenu.menu.add_command(label="Save CSV File", command=AWGAWriteFile)
24215  ShapeAMenu.menu.add_checkbutton(label='Burst', variable=AWGABurstFlag, command=AWGANumCycles)
24216  ShapeAMenu.menu.add_checkbutton(label='Repeat', variable=AWGARepeatFlag)
24217  ShapeAMenu.pack(side=LEFT, anchor=W)
24218  #
24219  awg1model = Frame( frame2r )
24220  awg1model.pack(side=TOP,fill=X) #)
24221  AWGAModeLabel = Label(awg1model, text="AWG A Mode", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
24222  AWGAModeLabel.pack(side=LEFT, fill=X)
24223  AWGAShapeLabel = Label(awg1model, text="AWG A Shape", background=COLORtrace1, font=('Arial', FontSize, 'bold'))
24224  AWGAShapeLabel.pack(side=LEFT, fill=X)
24225  #
24226  awg1ampl = Frame( frame2r )
24227  awg1ampl.pack(side=TOP,fill=X) #)
24228  amp1lab = Label(awg1ampl) #
24229  amp1lab.grid(row=0,column=0,sticky=E+S+N+W)
24230  off1lab = Label(awg1ampl) #
24231  off1lab.grid(row=0,column=1,sticky=E+S+N+W)
24232  freq1lab = Label(awg1ampl, text="Freq")
24233  freq1lab.grid(row=0,column=2,sticky=E+S+N+W)
24234  #
24235  AWGAAmplEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
24236  AWGAAmplEntry.bind("<Return>", UpdateAwgContRet)
24237  AWGAAmplEntry.bind('<MouseWheel>', onAWGAscroll)
24238  AWGAAmplEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24239  AWGAAmplEntry.bind("<Button-5>", onAWGAscroll)
24240  AWGAAmplEntry.bind('<Key>', onTextKeyAWG)
24241  AWGAAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
24242  AWGAAmplEntry.delete(0,"end")
24243  AWGAAmplEntry.insert(0,0.0)
24244  #
24245  AWGAOffsetEntry = Entry(awg1ampl, width=5, cursor='double_arrow')
24246  AWGAOffsetEntry.bind("<Return>", UpdateAwgContRet)
24247  AWGAOffsetEntry.bind('<MouseWheel>', onAWGAscroll)
24248  AWGAOffsetEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24249  AWGAOffsetEntry.bind("<Button-5>", onAWGAscroll)
24250  AWGAOffsetEntry.bind('<Key>', onTextKeyAWG)
24251  AWGAOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
24252  AWGAOffsetEntry.delete(0,"end")
24253  AWGAOffsetEntry.insert(0,0.0)
24254 
24255  if AWG_Amp_Mode.get() == 0:
24256  amp1lab.config(text = "Min" ) # change displayed value
24257  off1lab.config(text = "Max" ) # change displayed value
24258  else:
24259  amp1lab.config(text = "Amp" )
24260  off1lab.config(text = "Off" )
24261  # AWG Frequency sub frame
24262  AWGAFreqEntry = Entry(awg1ampl, width=7, cursor='double_arrow')
24263  AWGAFreqEntry.bind("<Return>", UpdateAwgContRet)
24264  AWGAFreqEntry.bind('<MouseWheel>', onAWGAscroll)
24265  AWGAFreqEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24266  AWGAFreqEntry.bind("<Button-5>", onAWGAscroll)
24267  AWGAFreqEntry.bind('<Key>', onTextKeyAWG)
24268  AWGAFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
24269  AWGAFreqEntry.delete(0,"end")
24270  AWGAFreqEntry.insert(0,100.0)
24271  # AWG Phase or delay select sub frame
24272  # AWG Phase entry sub frame
24273  awg1phase = Frame( frame2r )
24274  awg1phase.pack(side=TOP)
24275  awgaph = Button(awg1phase, text="Phase", style="W5.TButton", command=ToggleAWGAPhaseDelay)
24276  awgaph.pack(side=LEFT, anchor=W)
24277  AWGAPhaseEntry = Entry(awg1phase, width=4, cursor='double_arrow')
24278  AWGAPhaseEntry.bind("<Return>", UpdateAwgContRet)
24279  AWGAPhaseEntry.bind('<MouseWheel>', onAWGAscroll)
24280  AWGAPhaseEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24281  AWGAPhaseEntry.bind("<Button-5>", onAWGAscroll)
24282  AWGAPhaseEntry.bind('<Key>', onTextKeyAWG)
24283  AWGAPhaseEntry.pack(side=LEFT, anchor=W)
24284  AWGAPhaseEntry.delete(0,"end")
24285  AWGAPhaseEntry.insert(0,0)
24286  phasealab = Label(awg1phase, text="Deg")
24287  phasealab.pack(side=LEFT, anchor=W)
24288  # AWG duty cycle frame
24289  awg1dc = Frame( frame2r )
24290  awg1dc.pack(side=TOP)
24291  AWGADutyCycleEntry = Entry(awg1dc, width=5, cursor='double_arrow')
24292  AWGADutyCycleEntry.bind("<Return>", UpdateAwgContRet)
24293  AWGADutyCycleEntry.bind('<MouseWheel>', onAWGAscroll)
24294  AWGADutyCycleEntry.bind("<Button-4>", onAWGAscroll)# with Linux OS
24295  AWGADutyCycleEntry.bind("<Button-5>", onAWGAscroll)
24296  AWGADutyCycleEntry.bind('<Key>', onTextKeyAWG)
24297  AWGADutyCycleEntry.pack(side=LEFT, anchor=W)
24298  AWGADutyCycleEntry.delete(0,"end")
24299  AWGADutyCycleEntry.insert(0,50)
24300  duty1lab = Label(awg1dc, text="%")
24301  duty1lab.pack(side=LEFT, anchor=W)
24302 
24315  awg2eb = Frame( frame2r )
24316  awg2eb.pack(side=TOP)
24317  ModeBMenu = Menubutton(awg2eb, text="Mode", width=5, style="Ctrace2.TButton")# , style="W5.TButton")
24318  ModeBMenu.menu = Menu(ModeBMenu, tearoff = 0 )
24319  ModeBMenu["menu"] = ModeBMenu.menu
24320  ModeBMenu.menu.add_command(label="-Mode-", foreground="blue", command=donothing)
24321  ModeBMenu.menu.add_radiobutton(label="SVMI", variable=AWGBMode, value=0, command=BAWGBModeLabel)
24322  ModeBMenu.menu.add_radiobutton(label="SIMV", variable=AWGBMode, value=1, command=BAWGBModeLabel)
24323  ModeBMenu.menu.add_radiobutton(label="Hi-Z", variable=AWGBMode, value=2, command=BAWGBModeLabel)
24324  ModeBMenu.menu.add_checkbutton(label="Split I/O", variable=AWGBIOMode, command=BAWGBModeLabel)
24325  ModeBMenu.menu.add_separator()
24326  ModeBMenu.menu.add_command(label="-Term-", foreground="blue", command=donothing)
24327  ModeBMenu.menu.add_radiobutton(label="Open", variable=AWGBTerm, value=0, command=UpdateAwgCont)
24328  ModeBMenu.menu.add_radiobutton(label="To GND", variable=AWGBTerm, value=1, command=UpdateAwgCont)
24329  ModeBMenu.menu.add_radiobutton(label="To 2.5V", variable=AWGBTerm, value=2, command=UpdateAwgCont)
24330  ModeBMenu.pack(side=LEFT, anchor=W)
24331  ShapeBMenu = Menubutton(awg2eb, text="Shape", width=6, style="Ctrace2.TButton")#, style="W6.TButton")
24332  ShapeBMenu.menu = Menu(ShapeBMenu, tearoff = 0 )
24333  ShapeBMenu["menu"] = ShapeBMenu.menu
24334  ShapeBMenu.menu.add_command(label="-Basic-", foreground="blue", command=donothing)
24335  ShapeBMenu.menu.add_radiobutton(label="DC", variable=AWGBShape, value=0, command=ReMakeAWGwaves)
24336  ShapeBMenu.menu.add_radiobutton(label="Sine", variable=AWGBShape, value=18, command=ReMakeAWGwaves)
24337  ShapeBMenu.menu.add_radiobutton(label="Triangle", variable=AWGBShape, value=2, command=ReMakeAWGwaves)
24338  ShapeBMenu.menu.add_radiobutton(label="Sawtooth", variable=AWGBShape, value=3, command=ReMakeAWGwaves)
24339  ShapeBMenu.menu.add_radiobutton(label="Square", variable=AWGBShape, value=4, command=ReMakeAWGwaves)
24340  ShapeBMenu.menu.add_radiobutton(label="StairStep", variable=AWGBShape, value=5, command=ReMakeAWGwaves)
24341  if AWGShowAdvanced.get() > 0:
24342  ShapeBMenu.menu.add_command(label="-Advanced-", foreground="blue", command=donothing)
24343  ShapeBMenu.menu.add_radiobutton(label="Impulse", variable=AWGBShape, value=9, command=ReMakeAWGwaves)
24344  ShapeBMenu.menu.add_radiobutton(label="Trapezoid", variable=AWGBShape, value=11, command=ReMakeAWGwaves)
24345  ShapeBMenu.menu.add_radiobutton(label="Pulse", variable=AWGBShape, value=20, command=ReMakeAWGwaves)
24346  ShapeBMenu.menu.add_radiobutton(label="Ramp", variable=AWGBShape, value=16, command=ReMakeAWGwaves)
24347  ShapeBMenu.menu.add_radiobutton(label="SSQ Pulse", variable=AWGBShape, value=15, command=ReMakeAWGwaves)
24348  ShapeBMenu.menu.add_radiobutton(label="U-D Ramp", variable=AWGBShape, value=12, command=ReMakeAWGwaves)
24349  ShapeBMenu.menu.add_radiobutton(label="Fourier Series", variable=AWGBShape, value=14, command=AWGBMakeFourier)
24350  ShapeBMenu.menu.add_radiobutton(label="Sin X/X", variable=AWGBShape, value=19, command=ReMakeAWGwaves)
24351  ShapeBMenu.menu.add_radiobutton(label="PWM Sine", variable=AWGBShape, value=17, command=ReMakeAWGwaves)
24352  ShapeBMenu.menu.add_radiobutton(label="UU Noise", variable=AWGBShape, value=7, command=ReMakeAWGwaves)
24353  ShapeBMenu.menu.add_radiobutton(label="UG Noise", variable=AWGBShape, value=8, command=ReMakeAWGwaves)
24354  else:
24355  ShapeBMenu.menu.add_separator()
24356  ShapeBMenu.menu.add_radiobutton(label="Math", variable=AWGBShape, value=10, command=AWGBMakeMath)
24357  ShapeBMenu.menu.add_radiobutton(label="Read CSV File", variable=AWGBShape, value=6, command=AWGBReadFile)
24358  ShapeBMenu.menu.add_radiobutton(label="Read WAV File", variable=AWGBShape, value=13, command=AWGBReadWAV)
24359  ShapeBMenu.menu.add_command(label="Save CSV File", command=AWGBWriteFile)
24360  ShapeBMenu.menu.add_checkbutton(label='Burst', variable=AWGBBurstFlag, command=AWGBNumCycles)
24361  ShapeBMenu.menu.add_checkbutton(label='Repeat', variable=AWGBRepeatFlag)
24362  ShapeBMenu.pack(side=LEFT, anchor=W)
24363  #
24364  awg2model = Frame( frame2r )
24365  awg2model.pack(side=TOP,fill=X) #)
24366  AWGBModeLabel = Label(awg2model, text="AWG B Mode", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
24367  AWGBModeLabel.pack(side=LEFT, fill=X)
24368  AWGBShapeLabel = Label(awg2model, text="AWG B Shape", background=COLORtrace2, font=('Arial', FontSize, 'bold'))
24369  AWGBShapeLabel.pack(side=LEFT, fill=X)
24370  #
24371  awg2ampl = Frame( frame2r )
24372  awg2ampl.pack(side=TOP)
24373  amp2lab = Label(awg2ampl) #, text="Min Ch B")
24374  amp2lab.grid(row=0,column=0,sticky=E+S+N+W)
24375  #amp2lab.pack(side=LEFT, anchor=W)
24376  off2lab = Label(awg2ampl) #, text="Max Ch B")
24377  off2lab.grid(row=0,column=1,sticky=E+S+N+W)
24378  #off2lab.pack(side=LEFT, anchor=W)
24379  freq2lab = Label(awg2ampl, text="Freq")
24380  freq2lab.grid(row=0,column=2,sticky=E+S+N+W)
24381  # freq2lab.pack(side=LEFT, anchor=W)
24382  #
24383  AWGBAmplEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
24384  AWGBAmplEntry.bind("<Return>", UpdateAwgContRet)
24385  AWGBAmplEntry.bind('<MouseWheel>', onAWGBscroll)
24386  AWGBAmplEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24387  AWGBAmplEntry.bind("<Button-5>", onAWGBscroll)
24388  AWGBAmplEntry.bind('<Key>', onTextKeyAWG)
24389  AWGBAmplEntry.grid(row=1,column=0,sticky=E+S+N+W)
24390  AWGBAmplEntry.delete(0,"end")
24391  AWGBAmplEntry.insert(0,0.0)
24392  #
24393  AWGBOffsetEntry = Entry(awg2ampl, width=5, cursor='double_arrow')
24394  AWGBOffsetEntry.bind("<Return>", UpdateAwgContRet)
24395  AWGBOffsetEntry.bind('<MouseWheel>', onAWGBscroll)
24396  AWGBOffsetEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24397  AWGBOffsetEntry.bind("<Button-5>", onAWGBscroll)
24398  AWGBOffsetEntry.bind('<Key>', onTextKeyAWG)
24399  AWGBOffsetEntry.grid(row=1,column=1,sticky=E+S+N+W)
24400  AWGBOffsetEntry.delete(0,"end")
24401  AWGBOffsetEntry.insert(0,0.0)
24402 
24403  if AWG_Amp_Mode.get() == 0:
24404  amp2lab.config(text = "Min" ) # change displayed value
24405  off2lab.config(text = "Max" ) # change displayed value
24406  else:
24407  amp2lab.config(text = "Amp" )
24408  off2lab.config(text = "Off" )
24409  # AWG Frequency
24410  AWGBFreqEntry = Entry(awg2ampl, width=7, cursor='double_arrow')
24411  AWGBFreqEntry.bind("<Return>", UpdateAwgContRet)
24412  AWGBFreqEntry.bind('<MouseWheel>', onAWGBscroll)
24413  AWGBFreqEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24414  AWGBFreqEntry.bind("<Button-5>", onAWGBscroll)
24415  AWGBFreqEntry.bind('<Key>', onTextKeyAWG)
24416  AWGBFreqEntry.grid(row=1,column=2,sticky=E+S+N+W)
24417  AWGBFreqEntry.delete(0,"end")
24418  AWGBFreqEntry.insert(0,100.0)
24419  # AWG Phase or delay select sub frame
24420  # AWG Phase sub frame
24421  awg2phase = Frame( frame2r )
24422  awg2phase.pack(side=TOP)
24423  awgbph = Button(awg2phase, text="Phase", style="W5.TButton", command=ToggleAWGBPhaseDelay)
24424  awgbph.pack(side=LEFT, anchor=W)
24425  AWGBPhaseEntry = Entry(awg2phase, width=5, cursor='double_arrow')
24426  AWGBPhaseEntry.bind("<Return>", UpdateAwgContRet)
24427  AWGBPhaseEntry.bind('<MouseWheel>', onAWGBscroll)
24428  AWGBPhaseEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24429  AWGBPhaseEntry.bind("<Button-5>", onAWGBscroll)
24430  AWGBPhaseEntry.bind('<Key>', onTextKeyAWG)
24431  AWGBPhaseEntry.pack(side=LEFT, anchor=W)
24432  AWGBPhaseEntry.delete(0,"end")
24433  AWGBPhaseEntry.insert(0,0)
24434  phaseblab = Label(awg2phase, text="Deg")
24435  phaseblab.pack(side=LEFT, anchor=W)
24436  # AWG duty cycle frame
24437  awg2dc = Frame( frame2r )
24438  awg2dc.pack(side=TOP)
24439  AWGBDutyCycleEntry = Entry(awg2dc, width=5, cursor='double_arrow')
24440  AWGBDutyCycleEntry.bind("<Return>", UpdateAwgContRet)
24441  AWGBDutyCycleEntry.bind('<MouseWheel>', onAWGBscroll)
24442  AWGBDutyCycleEntry.bind("<Button-4>", onAWGBscroll)# with Linux OS
24443  AWGBDutyCycleEntry.bind("<Button-5>", onAWGBscroll)
24444  AWGBDutyCycleEntry.bind('<Key>', onTextKeyAWG)
24445  AWGBDutyCycleEntry.pack(side=LEFT, anchor=W)
24446  AWGBDutyCycleEntry.delete(0,"end")
24447  AWGBDutyCycleEntry.insert(0,50)
24448  duty2lab = Label(awg2dc, text="%")
24449  duty2lab.pack(side=LEFT, anchor=W)
24450  #
24451  bcompa = Checkbutton(frame2r, text="B = Comp A", variable=BisCompA, command=ReMakeAWGwaves)
24452  bcompa.pack(side=TOP)
24453 
24454  awgsync = Checkbutton(frame2r, text="Sync AWG", variable=AWGSync, command=BAWGSync)
24455  awgsync.pack(side=TOP)
24456  if ShowBallonHelp > 0:
24457  BuildAWGAPhase_tip = CreateToolTip(awgaph, 'Toggle between degrees and time')
24458  BuildAWGBPhase_tip = CreateToolTip(awgbph, 'Toggle between degrees and time')
24459  BuildAWGSync_tip = CreateToolTip(awgsync, 'Toggle between continuous and discontinuous modes')
24460  BuildBComp_tip = CreateToolTip(bcompa, 'Lock CH B to be the inverse of CH A')
24461  BuildModeAMenu_tip = CreateToolTip(ModeAMenu, 'Configure channel output mode')
24462  BuildModeBMenu_tip = CreateToolTip(ModeBMenu, 'Configure channel output mode')
24463  BuildShapeAMenu_tip = CreateToolTip(ShapeAMenu, 'Set channel waveform shape')
24464  BuildShapeBMenu_tip = CreateToolTip(ShapeBMenu, 'Set channel waveform shape')
24465 
24466 # input probe wigets
24467 prlab = Label(frame2r, text="Adjust Gain / Offset")
24468 prlab.pack(side=TOP)
24469 # Input Probes sub frame
24470 ProbeA = Frame( frame2r )
24471 ProbeA.pack(side=TOP)
24472 gain1lab = Button(ProbeA, text="CA-V", width=4, style="Ctrace1.TButton", command=ReSetAGO)
24473 gain1lab.pack(side=LEFT,fill=X)
24474 CHAVGainEntry = Entry(ProbeA, width=5, cursor='double_arrow')
24475 CHAVGainEntry.bind('<Return>', onTextKey)
24476 CHAVGainEntry.bind('<MouseWheel>', onTextScroll)
24477 CHAVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24478 CHAVGainEntry.bind("<Button-5>", onTextScroll)
24479 CHAVGainEntry.bind('<Key>', onTextKey)
24480 CHAVGainEntry.pack(side=LEFT)
24481 CHAVGainEntry.delete(0,"end")
24482 CHAVGainEntry.insert(0,1.0)
24483 CHAVOffsetEntry = Entry(ProbeA, width=5, cursor='double_arrow')
24484 CHAVOffsetEntry.bind('<Return>', onTextKey)
24485 CHAVOffsetEntry.bind('<MouseWheel>', onTextScroll)
24486 CHAVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24487 CHAVOffsetEntry.bind("<Button-5>", onTextScroll)
24488 CHAVOffsetEntry.bind('<Key>', onTextKey)
24489 CHAVOffsetEntry.pack(side=LEFT)
24490 CHAVOffsetEntry.delete(0,"end")
24491 CHAVOffsetEntry.insert(0,0.0)
24492 #
24493 ProbeB = Frame( frame2r )
24494 ProbeB.pack(side=TOP)
24495 gain2lab = Button(ProbeB, text="CB-V", width=4, style="Ctrace2.TButton", command=ReSetBGO)
24496 gain2lab.pack(side=LEFT,fill=X)
24497 CHBVGainEntry = Entry(ProbeB, width=5, cursor='double_arrow')
24498 CHBVGainEntry.bind('<Return>', onTextKey)
24499 CHBVGainEntry.bind('<MouseWheel>', onTextScroll)
24500 CHBVGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24501 CHBVGainEntry.bind("<Button-5>", onTextScroll)
24502 CHBVGainEntry.bind('<Key>', onTextKey)
24503 CHBVGainEntry.pack(side=LEFT)
24504 CHBVGainEntry.delete(0,"end")
24505 CHBVGainEntry.insert(0,1.0)
24506 CHBVOffsetEntry = Entry(ProbeB, width=5, cursor='double_arrow')
24507 CHBVOffsetEntry.bind('<Return>', onTextKey)
24508 CHBVOffsetEntry.bind('<MouseWheel>', onTextScroll)
24509 CHBVOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24510 CHBVOffsetEntry.bind("<Button-5>", onTextScroll)
24511 CHBVOffsetEntry.bind('<Key>', onTextKey)
24512 CHBVOffsetEntry.pack(side=LEFT)
24513 CHBVOffsetEntry.delete(0,"end")
24514 CHBVOffsetEntry.insert(0,0.0)
24515 #
24516 ProbeAI = Frame( frame2r )
24517 ProbeAI.pack(side=TOP)
24518 gainailab = Button(ProbeAI, text="CA-I", width=4, style="Ctrace3.TButton", command=ReSetAIGO)
24519 gainailab.pack(side=LEFT,fill=X)
24520 CHAIGainEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
24521 CHAIGainEntry.bind('<Return>', onTextKey)
24522 CHAIGainEntry.bind('<MouseWheel>', onTextScroll)
24523 CHAIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24524 CHAIGainEntry.bind("<Button-5>", onTextScroll)
24525 CHAIGainEntry.bind('<Key>', onTextKey)
24526 CHAIGainEntry.pack(side=LEFT)
24527 CHAIGainEntry.delete(0,"end")
24528 CHAIGainEntry.insert(0,1.0)
24529 CHAIOffsetEntry = Entry(ProbeAI, width=5, cursor='double_arrow')
24530 CHAIOffsetEntry.bind('<Return>', onTextKey)
24531 CHAIOffsetEntry.bind('<MouseWheel>', onTextScroll)
24532 CHAIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24533 CHAIOffsetEntry.bind("<Button-5>", onTextScroll)
24534 CHAIOffsetEntry.bind('<Key>', onTextKey)
24535 CHAIOffsetEntry.pack(side=LEFT)
24536 CHAIOffsetEntry.delete(0,"end")
24537 CHAIOffsetEntry.insert(0,0.0)
24538 #
24539 ProbeBI = Frame( frame2r )
24540 ProbeBI.pack(side=TOP)
24541 gainbilab = Button(ProbeBI, text="CB-I", width=4, style="Ctrace4.TButton", command=ReSetBIGO)
24542 gainbilab.pack(side=LEFT,fill=X)
24543 CHBIGainEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
24544 CHBIGainEntry.bind('<Return>', onTextKey)
24545 CHBIGainEntry.bind('<MouseWheel>', onTextScroll)
24546 CHBIGainEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24547 CHBIGainEntry.bind("<Button-5>", onTextScroll)
24548 CHBIGainEntry.bind('<Key>', onTextKey)
24549 CHBIGainEntry.pack(side=LEFT)
24550 CHBIGainEntry.delete(0,"end")
24551 CHBIGainEntry.insert(0,1.0)
24552 CHBIOffsetEntry = Entry(ProbeBI, width=5, cursor='double_arrow')
24553 CHBIOffsetEntry.bind('<Return>', onTextKey)
24554 CHBIOffsetEntry.bind('<MouseWheel>', onTextScroll)
24555 CHBIOffsetEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24556 CHBIOffsetEntry.bind("<Button-5>", onTextScroll)
24557 CHBIOffsetEntry.bind('<Key>', onTextKey)
24558 CHBIOffsetEntry.pack(side=LEFT)
24559 CHBIOffsetEntry.delete(0,"end")
24560 CHBIOffsetEntry.insert(0,0.0)
24561 # Add a pair of user entry wigets
24562 if EnableUserEntries > 0:
24563  UserEnt = Frame( frame2r )
24564  UserEnt.pack(side=TOP)
24565  userentlab = Button(UserEnt, text="User", width=4, style="W4.TButton")
24566  userentlab.pack(side=LEFT,fill=X)
24567  User1Entry = Entry(UserEnt, width=5, cursor='double_arrow')
24568  User1Entry.bind('<Return>', onTextKey)
24569  User1Entry.bind('<MouseWheel>', onTextScroll)
24570  User1Entry.bind("<Button-4>", onTextScroll)# with Linux OS
24571  User1Entry.bind("<Button-5>", onTextScroll)
24572  User1Entry.bind('<Key>', onTextKey)
24573  User1Entry.pack(side=LEFT)
24574  User1Entry.delete(0,"end")
24575  User1Entry.insert(0,0.0)
24576  User2Entry = Entry(UserEnt, width=5, cursor='double_arrow')
24577  User2Entry.bind('<Return>', onTextKey)
24578  User2Entry.bind('<MouseWheel>', onTextScroll)
24579  User2Entry.bind("<Button-4>", onTextScroll)# with Linux OS
24580  User2Entry.bind("<Button-5>", onTextScroll)
24581  User2Entry.bind('<Key>', onTextKey)
24582  User2Entry.pack(side=LEFT)
24583  User2Entry.delete(0,"end")
24584  User2Entry.insert(0,0.0)
24585 # add ADI logo Don't mess with this bit map data!
24586 ADIlogo = """
24587 R0lGODlhdAAxAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/
24588 /////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
24589 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBm
24590 AABmMwBmZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/
24591 MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNm
24592 ZjNmmTNmzDNm/zOZADOZMzOZZjOZmTOZzDOZ/zPMADPMMzPMZjPMmTPMzDPM/zP/ADP/MzP/ZjP/
24593 mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YzAGYzM2YzZmYzmWYzzGYz/2ZmAGZmM2ZmZmZmmWZm
24594 zGZm/2aZAGaZM2aZZmaZmWaZzGaZ/2bMAGbMM2bMZmbMmWbMzGbM/2b/AGb/M2b/Zmb/mWb/zGb/
24595 /5kAAJkAM5kAZpkAmZkAzJkA/5kzAJkzM5kzZpkzmZkzzJkz/5lmAJlmM5lmZplmmZlmzJlm/5mZ
24596 AJmZM5mZZpmZmZmZzJmZ/5nMAJnMM5nMZpnMmZnMzJnM/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwA
24597 M8wAZswAmcwAzMwA/8wzAMwzM8wzZswzmcwzzMwz/8xmAMxmM8xmZsxmmcxmzMxm/8yZAMyZM8yZ
24598 ZsyZmcyZzMyZ/8zMAMzMM8zMZszMmczMzMzM/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8A
24599 mf8AzP8A//8zAP8zM/8zZv8zmf8zzP8z//9mAP9mM/9mZv9mmf9mzP9m//+ZAP+ZM/+ZZv+Zmf+Z
24600 zP+Z///MAP/MM//MZv/Mmf/MzP/M////AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAB0ADEA
24601 AAj/AP8JHEiwoMGDCBMqXMiwocOHEBlSS5WKIUWJfqj9S+XnokGPEUOKdEito0WNCC9OpEbtz7+V
24602 HyuOnEnzI6yMEylWpNgx50aOGkt6LElUoB9VPFHyTAXrYipVNaOSTOWzEEuqA61SXTnxH06ZK7EK
24603 5Ap2J9WdKKWqRVjyJ1c/1ZbqvPnyrKqS215mzEiwo8yfer22XUs4Zse9V31mPFuxbdKxjAU65Si5
24604 8Vm+hTNXrvuWKFKdjs8WJEqR5V63bkP/1bx28E+rK28ihckRayHQnH/yVdUTMtB/1fywHj7TI0iR
24605 x4krd7g0bcjSy6NLn069uvXr2LNr3/6Sip/vU777//EOXjx5P+G/nw/vnCA18gXFOy+JWfL31V6/
24606 s001ZQqK8AdN1B8KJiVETX9TMIGggv0xmOCCEDbYX3sDoTdhXwi6199qFjJRUIMB3iEhgs7x56CC
24607 wrH134r+tcjiiy7G+B+FL7nIYYsp1ojCX9SwuFqLBh343xQc+bGiUjhyhCNbLTbR4oBTODlkk09S
24608 iQKNBz7Z139OotQjkQPxx2WO/3D5kZNUDDSRk8IJOUVabqoo45ww1tkijejt+N9fUM64kX9/GQne
24609 lQMBWdCRGs6Yyp4FFYllhIVM6aCkCFL65kGAHshEjhZa2NiGAlWzJzUK8pngaAmSKVAh/fHWX0Rf
24610 sv+oSnB01iprkIwOWKF//wzIEqBG8drrf4USS9CiYBYEy39/GCrQHzpZFWCVhOoFpZSVRkktheg1
24611 MRaoXhGLbEaM9tpEinmiNGSj4CaaipNTqKltuaPBOF+ftt6JKgpUnGUoFcIaGR6wX371X4rOjnXw
24612 R3tSYexLL+L37YgUmhjhgxSjijHGGln4rYMVoXdihr2eqiETdxhEooUUtuuevQEiayeL7eU5p3B5
24613 ZmXjsHRWlLBAWgA7ULME/rPsqxjuOC2X/tE4VrfUztuef6oCKXDSRBb8MoBc6gSalD1BDVW4E5rW
24614 osQQx+i0mgLbOd/CSWeJwtY7pvvhjLWmDWOOJc3/jHaWHDckd4TOsawxePEeuyGJ7O44opbWDukH
24615 LB8hOGFtAcI4dkNEx7g5d+6xtBBLa8s7ZbUk/XF66aBLFau+D/GntntbwdQo6bXnHmTu83FFO+6k
24616 wxm8QoAzyDrbI186UPIF/vk4in6UStA2DKaC4q4OKp98qsFmnPnsC21jM8zF3izZzB1RTRDRfrBa
24617 dMl1alSrcPgOmVeQVpYuYNRSOtf/RFDbSaaCJzop9cVJFOkPzs6mF3iVjEheo0qzmvAHpcCtXuA7
24618 iJjy5ZyE2Wwi9IpPub4ULzFlhIFP25P6DCKwzQlJVRML3EEstDFLOYdBH7qcyxQ3hUJIJkE7ORip
24619 /5CmptJcEENMQNv3bkW7mc3pcz8bl8xilKN1ka0i7HMfDMsHo42wqIdiWVqlSmSlbGHLVwTRleII
24620 tMFrccpPVnxXeGSnxH+csUk/tFJ96Aa7kuTLbWl82PnmKLn06OeHOxKTTExowoTgCD3i6UvbVqix
24621 wMlue5i80PKIuKoN0VEhCJLd2KzHnushxJSjuySFXnewP3IwkIkrH0WYpRCBkewfWnSTc1TRyvfF
24622 RwuqEtgqy3gt/hkTdXYUVl0cqEiFyE5ozlugL+GXpS32pwkdjNIqncjNWnXwYBZaEVSm+CIyQekv
24623 jYTffaDkpjqpzpOym6a8HmepKk2KcAS5J+OcV0JDAIXJioPMEZQaxJd6Kkqfe1RTNxfquWNRBFo6
24624 oV0qbvNQ6BQxjP/4TOGSpBSKUDQVEH2awHrTupKa9KQoTWl0AgIAOw==
24625 """
24626 logo = PhotoImage(data=ADIlogo)
24627 ADI1 = Label(frame2r, image=logo, anchor= "sw", compound="top") # , height=49, width=116
24628 ADI1.pack(side=TOP)
24629 
24630 # Bottom Buttons
24631 # Voltage channel A
24632 if ButtonOrder == 1:
24633  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
24634  CHAlab.pack(side=LEFT)
24635 CHAsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHvpdiv, command=BCHAlevel)
24636 #CHAsb = ttk.Spinbox(frame3, cursor='double_arrow', style="Div.TSpinbox", values=CHvpdiv, command=BCHAlevel)
24637 CHAsb.bind('<MouseWheel>', onSpinBoxScroll)
24638 CHAsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24639 CHAsb.bind("<Button-5>", onSpinBoxScroll)
24640 CHAsb.pack(side=LEFT)
24641 CHAsb.delete(0,"end")
24642 CHAsb.insert(0,0.5)
24643 #
24644 if ButtonOrder == 0:
24645  CHAlab = Button(frame3, text="CA V/Div", style="Rtrace1.TButton", command=SetScaleA)
24646  CHAlab.pack(side=LEFT)
24647 #
24648 if ButtonOrder == 1:
24649  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
24650  CHAofflab.pack(side=LEFT)
24651 CHAVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24652 CHAVPosEntry.bind("<Return>", BOffsetA)
24653 CHAVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24654 CHAVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24655 CHAVPosEntry.bind("<Button-5>", onTextScroll)
24656 CHAVPosEntry.bind('<Key>', onTextKey)
24657 CHAVPosEntry.pack(side=LEFT)
24658 CHAVPosEntry.delete(0,"end")
24659 CHAVPosEntry.insert(0,2.5)
24660 if ButtonOrder == 0:
24661  CHAofflab = Button(frame3, text="CA V Pos", style="Rtrace1.TButton", command=SetVAPoss)
24662  CHAofflab.pack(side=LEFT)
24663 # Current channel A
24664 if ButtonOrder == 1:
24665  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
24666  CHAIlab.pack(side=LEFT)
24667 CHAIsb = Spinbox(frame3, cursor='double_arrow', width=4, values=CHipdiv, command=BCHAIlevel)
24668 CHAIsb.bind('<MouseWheel>', onSpinBoxScroll)
24669 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24670 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
24671 CHAIsb.pack(side=LEFT)
24672 CHAIsb.delete(0,"end")
24673 CHAIsb.insert(0,50.0)
24674 if ButtonOrder == 0:
24675  CHAIlab = Button(frame3, text="CA mA/Div", style="Strace3.TButton", command=SetScaleIA)
24676  CHAIlab.pack(side=LEFT)
24677 #
24678 if ButtonOrder == 1:
24679  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
24680  CHAIofflab.pack(side=LEFT)
24681 CHAIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24682 CHAIPosEntry.bind("<Return>", BIOffsetA)
24683 CHAIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24684 CHAIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24685 CHAIPosEntry.bind("<Button-5>", onTextScroll)
24686 CHAIPosEntry.bind('<Key>', onTextKey)
24687 CHAIPosEntry.pack(side=LEFT)
24688 CHAIPosEntry.delete(0,"end")
24689 CHAIPosEntry.insert(0,0.0)
24690 if ButtonOrder == 0:
24691  CHAIofflab = Button(frame3, text="CA I Pos", style="Rtrace3.TButton", command=SetIAPoss)
24692  CHAIofflab.pack(side=LEFT)
24693 # Voltage channel B
24694 if ButtonOrder == 1:
24695  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
24696  CHBlab.pack(side=LEFT)
24697 CHBsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHvpdiv, command=BCHBlevel)
24698 CHBsb.bind('<MouseWheel>', onSpinBoxScroll)
24699 CHAIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24700 CHAIsb.bind("<Button-5>", onSpinBoxScroll)
24701 CHBsb.pack(side=LEFT)
24702 CHBsb.delete(0,"end")
24703 CHBsb.insert(0,0.5)
24704 #
24705 if ButtonOrder == 0:
24706  CHBlab = Button(frame3, text="CB V/Div", style="Strace2.TButton", command=SetScaleB)
24707  CHBlab.pack(side=LEFT)
24708 #
24709 if ButtonOrder == 1:
24710  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
24711  CHBofflab.pack(side=LEFT)
24712 CHBVPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24713 CHBVPosEntry.bind("<Return>", BOffsetB)
24714 CHBVPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24715 CHBVPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24716 CHBVPosEntry.bind("<Button-5>", onTextScroll)
24717 CHBVPosEntry.bind('<Key>', onTextKey)
24718 CHBVPosEntry.pack(side=LEFT)
24719 CHBVPosEntry.delete(0,"end")
24720 CHBVPosEntry.insert(0,2.5)
24721 if ButtonOrder == 0:
24722  CHBofflab = Button(frame3, text="CB V Pos", style="Rtrace2.TButton", command=SetVBPoss)
24723  CHBofflab.pack(side=LEFT)
24724 # Current channel B
24725 if ButtonOrder == 1:
24726  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
24727  CHBIlab.pack(side=LEFT)
24728 CHBIsb = Spinbox(frame3, width=4, cursor='double_arrow', values=CHipdiv, command=BCHBIlevel)
24729 CHBIsb.bind('<MouseWheel>', onSpinBoxScroll)
24730 CHBIsb.bind("<Button-4>", onSpinBoxScroll)# with Linux OS
24731 CHBIsb.bind("<Button-5>", onSpinBoxScroll)
24732 CHBIsb.pack(side=LEFT)
24733 CHBIsb.delete(0,"end")
24734 CHBIsb.insert(0,50.0)
24735 if ButtonOrder == 0:
24736  CHBIlab = Button(frame3, text="CB mA/Div", style="Strace4.TButton", command=SetScaleIB)
24737  CHBIlab.pack(side=LEFT)
24738 #
24739 if ButtonOrder == 1:
24740  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
24741  CHBIofflab.pack(side=LEFT)
24742 CHBIPosEntry = Entry(frame3, width=5, cursor='double_arrow')
24743 CHBIPosEntry.bind("<Return>", BIOffsetB)
24744 CHBIPosEntry.bind('<MouseWheel>', onTextScroll)# with Windows OS
24745 CHBIPosEntry.bind("<Button-4>", onTextScroll)# with Linux OS
24746 CHBIPosEntry.bind("<Button-5>", onTextScroll)
24747 CHBIPosEntry.bind('<Key>', onTextKey)
24748 CHBIPosEntry.pack(side=LEFT)
24749 CHBIPosEntry.delete(0,"end")
24750 CHBIPosEntry.insert(0,0.0)
24751 if ButtonOrder == 0:
24752  CHBIofflab = Button(frame3, text="CB I Pos", style="Rtrace4.TButton", command=SetIBPoss)
24753  CHBIofflab.pack(side=LEFT)
24754 #
24755 if ShowBallonHelp > 0:
24756  CHAlab_tip = CreateToolTip(CHAlab, 'Select CHA-V vertical range/position axis to be used for markers and drawn color')
24757  CHBlab_tip = CreateToolTip(CHBlab, 'Select CHB-V vertical range/position axis to be used for markers and drawn color')
24758  CHAIlab_tip = CreateToolTip(CHAIlab, 'Select CHA-I vertical range/position axis to be used for markers and drawn color')
24759  CHBIlab_tip = CreateToolTip(CHBIlab, 'Select CHB-I vertical range/position axis to be used for markers and drawn color')
24760  CHAofflab_tip = CreateToolTip(CHAofflab, 'Set CHA-V position to DC average of signal')
24761  CHBofflab_tip = CreateToolTip(CHBofflab, 'Set CHB-V position to DC average of signal')
24762  CHAIofflab_tip = CreateToolTip(CHAIofflab, 'Set CHA-I position to DC average of signal')
24763  CHBIofflab_tip = CreateToolTip(CHBIofflab, 'Set CHB-I position to DC average of signal')
24764  gain1lab_tip = CreateToolTip(gain1lab, 'Reset Gain to 1.0 and Offset to 0.0')
24765  gain2lab_tip = CreateToolTip(gain2lab, 'Reset Gain to 1.0 and Offset to 0.0')
24766  gainailab_tip = CreateToolTip(gainailab, 'Reset Gain to 1.0 and Offset to 0.0')
24767  gainbilab_tip = CreateToolTip(gainbilab, 'Reset Gain to 1.0 and Offset to 0.0')
24768 #
24769 root.geometry('+300+0')
24770 root.protocol("WM_DELETE_WINDOW", Bcloseexit)
24771 #===== Initalize device ======
24772 if not numpy_found:
24773  root.update()
24774  showwarning("WARNING","Numpy not found!")
24775  root.destroy()
24776  exit()
24777 #
24778 BrdSel = IntVar(0)
24779 BoardStatus = IntVar(0)
24780 if pysmu_found:
24781  ConnectDevice()
24782  #session.hotplug_attach(ConnectDevice)
24783  #session.hotplug_detach(ConnectDevice)
24784  if EnableScopeOnly == 0:
24785  MakeAWGWindow() # build AWG window
24786  else:
24787  AWGScreenStatus.set(1)
24788  # root.update()
24789  BLoadConfig("alice-last-config.cfg") # load configuration from last session
24790  if LocalLanguage != "English":
24791  BLoadConfig(LocalLanguage) # load local language configuration
24792 # ================ Call main routine ===============================
24793  root.update() # Activate updated screens
24794 # Start sampling
24795  Analog_In()
24796 else:
24797  root.update()
24798  showwarning("WARNING","Pysmu not found!")
24799  root.destroy()
24800  exit()
24801 
alice-desktop-1.UpdateNqPAll
def UpdateNqPAll()
Definition: alice-desktop-1.3.pyw:15751
alice-desktop-1.AWGBMakeRamp
def AWGBMakeRamp()
Definition: alice-desktop-1.3.pyw:12252
alice-desktop-1.DestroyNiCScreen
def DestroyNiCScreen()
Definition: alice-desktop-1.3.pyw:15609
alice-desktop-1.SetETSComp
def SetETSComp()
Definition: alice-desktop-1.3.pyw:22995
alice-desktop-1.DestroySettings
def DestroySettings()
Definition: alice-desktop-1.3.pyw:23219
alice-desktop-1.MakeNqPScreen
def MakeNqPScreen()
Draw the Nyquist plot screen.
Definition: alice-desktop-1.3.pyw:15499
alice-desktop-1.BResetFreqAvg
def BResetFreqAvg()
Definition: alice-desktop-1.3.pyw:12819
alice-desktop-1.onCanvasOne
def onCanvasOne(event)
Definition: alice-desktop-1.3.pyw:9591
alice-desktop-1.DestroyDigScreen
def DestroyDigScreen()
Distroy the Digital I/O screen.
Definition: alice-desktop-1.3.pyw:5599
alice-desktop-1.onRetAWGFiltB
def onRetAWGFiltB(event)
Definition: alice-desktop-1.3.pyw:21549
alice-desktop-1.MGLoad
def MGLoad()
Definition: alice-desktop-1.3.pyw:22591
alice-desktop-1.DestroyDacScreen
def DestroyDacScreen()
Destroy the DAC Screen.
Definition: alice-desktop-1.3.pyw:5789
alice-desktop-1.BLoadConfig
def BLoadConfig(filename)
Load configuration from a file
Definition: alice-desktop-1.3.pyw:1573
alice-desktop-1.ReInterploateTrigger
def ReInterploateTrigger(TrgBuff)
Interpolate time between samples around trigger event.
Definition: alice-desktop-1.3.pyw:5469
alice-desktop-1.MakeCommandScreen
def MakeCommandScreen()
Definition: alice-desktop-1.3.pyw:21705
alice-desktop-1.UpdateNiCScreen
def UpdateNiCScreen()
Definition: alice-desktop-1.3.pyw:15784
alice-desktop-1.onCanvasFreqClickScroll
def onCanvasFreqClickScroll(event)
Definition: alice-desktop-1.3.pyw:17687
alice-desktop-1.onCanvasMouse_xy
def onCanvasMouse_xy(event)
Definition: alice-desktop-1.3.pyw:23226
alice-desktop-1.onCanvasSnap
def onCanvasSnap(event)
Definition: alice-desktop-1.3.pyw:9663
alice-desktop-1.TimeSeriesNoise
def TimeSeriesNoise(n, Fsample, mag, b=4)
Definition: alice-desktop-1.3.pyw:9921
alice-desktop-1.onCanvasBdSeven
def onCanvasBdSeven(event)
Definition: alice-desktop-1.3.pyw:18070
alice-desktop-1.ToggleAWGAPhaseDelay
def ToggleAWGAPhaseDelay()
Definition: alice-desktop-1.3.pyw:10206
alice-desktop-1.onCanvasSATwo
def onCanvasSATwo(event)
Definition: alice-desktop-1.3.pyw:17825
alice-desktop-1.SetTriggerPoss
def SetTriggerPoss()
Definition: alice-desktop-1.3.pyw:2794
alice-desktop-1.shift_buffer
def shift_buffer(arr, num, fill_value=numpy.nan)
Function to left (-num) or right (+num) shift buffer and fill with a value returns same length buffer...
Definition: alice-desktop-1.3.pyw:4957
alice-desktop-1.BTime
def BTime()
Set Hor time scale from entry widget.
Definition: alice-desktop-1.3.pyw:3141
alice-desktop-1.OpenOtherTools
def OpenOtherTools()
Definition: alice-desktop-1.3.pyw:23272
alice-desktop-1.VAtoggle
def VAtoggle()
Definition: alice-desktop-1.3.pyw:15790
alice-desktop-1.onCanvasSpaceBar
def onCanvasSpaceBar(event)
Pause / start on space bar.
Definition: alice-desktop-1.3.pyw:9280
alice-desktop-1.SetXYScaleB
def SetXYScaleB()
Definition: alice-desktop-1.3.pyw:9051
alice-desktop-1.MakeAWGWindow
def MakeAWGWindow()
Definition: alice-desktop-1.3.pyw:18241
alice-desktop-1.MakeFreqTrace
def MakeFreqTrace()
Definition: alice-desktop-1.3.pyw:13741
alice-desktop-1.BDSweepFromFile
def BDSweepFromFile()
Definition: alice-desktop-1.3.pyw:18956
alice-desktop-1.ReSetBGO
def ReSetBGO()
Definition: alice-desktop-1.3.pyw:23248
alice-desktop-1.SetMuxBPoss
def SetMuxBPoss()
Definition: alice-desktop-1.3.pyw:2836
alice-desktop-1.sel
def sel()
Definition: alice-desktop-1.3.pyw:5605
alice-desktop-1.MakeNyquistPlot
def MakeNyquistPlot()
Definition: alice-desktop-1.3.pyw:15457
alice-desktop-1.MakeXYWindow
def MakeXYWindow()
Definition: alice-desktop-1.3.pyw:19662
alice-desktop-1.AWGBMakeUpDownRamp
def AWGBMakeUpDownRamp()
Definition: alice-desktop-1.3.pyw:12314
alice-desktop-1.DoImpedance
def DoImpedance()
Definition: alice-desktop-1.3.pyw:14679
alice-desktop-1.BAWGBOffset
def BAWGBOffset(temp)
Definition: alice-desktop-1.3.pyw:11557
alice-desktop-1.onAWGBscroll
def onAWGBscroll(event)
Definition: alice-desktop-1.3.pyw:18121
alice-desktop-1.Analog_Chop_Time
def Analog_Chop_Time()
Definition: alice-desktop-1.3.pyw:4093
alice-desktop-1.MakeSpectrumWindow
def MakeSpectrumWindow()
Definition: alice-desktop-1.3.pyw:19325
alice-desktop-1.SettingsUpdate
def SettingsUpdate()
Definition: alice-desktop-1.3.pyw:23035
alice-desktop-1.BAWGBPhaseDelay
def BAWGBPhaseDelay()
Definition: alice-desktop-1.3.pyw:11638
alice-desktop-1.MakeXYScreen
def MakeXYScreen()
Update the XY screen traces and text.
Definition: alice-desktop-1.3.pyw:8226
alice-desktop-1.UpdateFirmware
def UpdateFirmware()
Definition: alice-desktop-1.3.pyw:22365
alice-desktop-1.UpdateBodeScreen
def UpdateBodeScreen()
Definition: alice-desktop-1.3.pyw:13383
alice-desktop-1.UpdateAWGB
def UpdateAWGB()
Definition: alice-desktop-1.3.pyw:12544
alice-desktop-1.MakeBodeWindow
def MakeBodeWindow()
Definition: alice-desktop-1.3.pyw:19001
alice-desktop-1.BPower
def BPower()
Toggel on/off analog power.
Definition: alice-desktop-1.3.pyw:3116
alice-desktop-1.CAresize
def CAresize(event)
Definition: alice-desktop-1.3.pyw:21811
alice-desktop-1.BSweepSync
def BSweepSync()
Definition: alice-desktop-1.3.pyw:18946
alice-desktop-1.BDFiltAMath
def BDFiltAMath()
Definition: alice-desktop-1.3.pyw:21470
alice-desktop-1.SetScaleA
def SetScaleA()
Definition: alice-desktop-1.3.pyw:8996
alice-desktop-1.fit_exp
def fit_exp(xs, ys)
Definition: alice-desktop-1.3.pyw:21688
alice-desktop-1.DestroyMuxScreen
def DestroyMuxScreen()
Definition: alice-desktop-1.3.pyw:18911
alice-desktop-1.SetScaleMuxA
def SetScaleMuxA()
Definition: alice-desktop-1.3.pyw:2854
alice-desktop-1.BSaveScreenXY
def BSaveScreenXY()
Save XY canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2044
alice-desktop-1.PlotPhAFromFile
def PlotPhAFromFile()
Definition: alice-desktop-1.3.pyw:16932
alice-desktop-1.DA1ShiftOut
def DA1ShiftOut(D1Value, D2Value)
if ETSStatus.get() > 0 and ETSDisp.get() > 0: MGLoad()
Definition: alice-desktop-1.3.pyw:20684
alice-desktop-1.Analog_In
def Analog_In()
Main Loop.
Definition: alice-desktop-1.3.pyw:3357
alice-desktop-1.IACheckBox
def IACheckBox()
Definition: alice-desktop-1.3.pyw:3307
alice-desktop-1.AWGALoadWAV
def AWGALoadWAV()
Definition: alice-desktop-1.3.pyw:10385
alice-desktop-1.BSaveIASweep
def BSaveIASweep()
Definition: alice-desktop-1.3.pyw:15438
alice-desktop-1.AWGAMakePulse
def AWGAMakePulse()
Definition: alice-desktop-1.3.pyw:10936
alice-desktop-1.ApplyMathString
def ApplyMathString()
Apply Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2642
alice-desktop-1.AWGAMakeUpDownRamp
def AWGAMakeUpDownRamp()
Definition: alice-desktop-1.3.pyw:11070
alice-desktop-1.onCanvasShowdBcur
def onCanvasShowdBcur(event)
Definition: alice-desktop-1.3.pyw:17901
alice-desktop-1.BAWGFiltBMath
def BAWGFiltBMath()
Definition: alice-desktop-1.3.pyw:21640
alice-desktop-1.DestroyAD5626Screen
def DestroyAD5626Screen()
Definition: alice-desktop-1.3.pyw:21121
alice-desktop-1.SplitAWGAwaveform
def SplitAWGAwaveform()
Definition: alice-desktop-1.3.pyw:10342
alice-desktop-1.BStartIA
def BStartIA()
Start Impedance Tool
Definition: alice-desktop-1.3.pyw:3050
alice-desktop-1.SetBCompA
def SetBCompA()
Definition: alice-desktop-1.3.pyw:11467
alice-desktop-1.onCanvasSAAverage
def onCanvasSAAverage(event)
Definition: alice-desktop-1.3.pyw:17891
alice-desktop-1.MakeETSWindow
def MakeETSWindow()
Definition: alice-desktop-1.3.pyw:22484
alice-desktop-1.SplitAWGBwaveform
def SplitAWGBwaveform()
Definition: alice-desktop-1.3.pyw:11763
alice-desktop-1.BSendDA1
def BSendDA1()
Definition: alice-desktop-1.3.pyw:20722
alice-desktop-1.SetVBPoss
def SetVBPoss()
Definition: alice-desktop-1.3.pyw:2908
alice-desktop-1.AWGBMakeUGNoise
def AWGBMakeUGNoise()
Definition: alice-desktop-1.3.pyw:12479
alice-desktop-1.BCHBIlevel
def BCHBIlevel()
Definition: alice-desktop-1.3.pyw:3207
alice-desktop-1.ETSscroll
def ETSscroll(event)
Definition: alice-desktop-1.3.pyw:22601
alice-desktop-1.Bsamples1
def Bsamples1()
Definition: alice-desktop-1.3.pyw:13112
alice-desktop-1.BAWGADutyCycle
def BAWGADutyCycle(temp)
Definition: alice-desktop-1.3.pyw:10246
alice-desktop-1.RunScript
def RunScript()
Run a script file.
Definition: alice-desktop-1.3.pyw:1913
alice-desktop-1.BAWG2X
def BAWG2X()
Definition: alice-desktop-1.3.pyw:18619
alice-desktop-1.ReSetAIGO
def ReSetAIGO()
Definition: alice-desktop-1.3.pyw:23256
alice-desktop-1.onCanvasShowBdBcur
def onCanvasShowBdBcur(event)
Definition: alice-desktop-1.3.pyw:18099
alice-desktop-1.onRetSrate
def onRetSrate(event)
Definition: alice-desktop-1.3.pyw:22176
alice-desktop-1.BAveragemode
def BAveragemode()
Definition: alice-desktop-1.3.pyw:12809
alice-desktop-1.SetScaleIB
def SetScaleIB()
Definition: alice-desktop-1.3.pyw:9032
alice-desktop-1.onRetAWGFiltA
def onRetAWGFiltA(event)
Definition: alice-desktop-1.3.pyw:21523
alice-desktop-1.AWGBWriteFile
def AWGBWriteFile()
Definition: alice-desktop-1.3.pyw:11818
alice-desktop-1.Blevel4
def Blevel4()
Definition: alice-desktop-1.3.pyw:13103
alice-desktop-1.BReadData
def BReadData()
Read scope all time array data from saved file.
Definition: alice-desktop-1.3.pyw:2176
alice-desktop-1.MakeFreqScreen
def MakeFreqScreen()
Make Spectrum Analyzer Screen.
Definition: alice-desktop-1.3.pyw:17072
alice-desktop-1.Blevel1
def Blevel1()
Definition: alice-desktop-1.3.pyw:13076
alice-desktop-1.BHistAsPercent
def BHistAsPercent()
Plot Histogram as Percent?
Definition: alice-desktop-1.3.pyw:5310
alice-desktop-1.UpdateTimeTrace
def UpdateTimeTrace()
Update time trace and screen.
Definition: alice-desktop-1.3.pyw:5954
alice-desktop-1.onCanvasBdOne
def onCanvasBdOne(event)
Definition: alice-desktop-1.3.pyw:18028
alice-desktop-1.BSaveScreen
def BSaveScreen()
Save scope canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2025
alice-desktop-1.UpdateNiCAll
def UpdateNiCAll()
Definition: alice-desktop-1.3.pyw:15770
alice-desktop-1.Blevel2BP
def Blevel2BP()
Definition: alice-desktop-1.3.pyw:13309
alice-desktop-1.onSpinBoxScroll
def onSpinBoxScroll(event)
Definition: alice-desktop-1.3.pyw:18231
alice-desktop-1.onCanvasSASnap
def onCanvasSASnap(event)
Definition: alice-desktop-1.3.pyw:17879
alice-desktop-1.BAWGEnab
def BAWGEnab()
Definition: alice-desktop-1.3.pyw:12711
alice-desktop-1.BIOffsetB
def BIOffsetB(event)
Definition: alice-desktop-1.3.pyw:3254
alice-desktop-1.SetScaleMuxD
def SetScaleMuxD()
Definition: alice-desktop-1.3.pyw:2890
alice-desktop-1.AWGBMakeSinc
def AWGBMakeSinc()
Definition: alice-desktop-1.3.pyw:12003
alice-desktop-1.AWGBReadWAV
def AWGBReadWAV()
Definition: alice-desktop-1.3.pyw:11783
alice-desktop-1.UpdateTimeAll
def UpdateTimeAll()
Update Data, trace and time screen.
Definition: alice-desktop-1.3.pyw:5949
alice-desktop-1.onCanvasSASeven
def onCanvasSASeven(event)
Definition: alice-desktop-1.3.pyw:17860
alice-desktop-1.Bcloseexit
def Bcloseexit()
Fubntion to close and exit ALICE.
Definition: alice-desktop-1.3.pyw:2950
alice-desktop-1.AWGAMakePWMSine
def AWGAMakePWMSine()
Definition: alice-desktop-1.3.pyw:10675
alice-desktop-1.Sine_Phase
def Sine_Phase()
Definition: alice-desktop-1.3.pyw:4894
alice-desktop-1.CreateToolTip.tw
tw
Definition: alice-desktop-1.3.pyw:886
alice-desktop-1.MakeIAWindow
def MakeIAWindow()
Definition: alice-desktop-1.3.pyw:15234
alice-desktop-1.SetScaleB
def SetScaleB()
Definition: alice-desktop-1.3.pyw:9020
alice-desktop-1.SetXYScaleA
def SetXYScaleA()
Definition: alice-desktop-1.3.pyw:9044
alice-desktop-1.TraceSelectADC_Mux
def TraceSelectADC_Mux()
Definition: alice-desktop-1.3.pyw:22325
alice-desktop-1.SetXYIAPoss
def SetXYIAPoss()
Definition: alice-desktop-1.3.pyw:2938
alice-desktop-1.SetSampleRate
def SetSampleRate()
Definition: alice-desktop-1.3.pyw:22180
alice-desktop-1.BSaveConfigTime
def BSaveConfigTime()
Save current configuration from Scope window.
Definition: alice-desktop-1.3.pyw:1568
alice-desktop-1.MakeHistogram
def MakeHistogram()
Make histogram of time signals.
Definition: alice-desktop-1.3.pyw:5269
alice-desktop-1.SetScaleIA
def SetScaleIA()
Definition: alice-desktop-1.3.pyw:9008
alice-desktop-1.BFileFFTwindow
def BFileFFTwindow()
Definition: alice-desktop-1.3.pyw:17653
alice-desktop-1.IncHoldOff
def IncHoldOff()
Definition: alice-desktop-1.3.pyw:2812
alice-desktop-1.BAWGBModeLabel
def BAWGBModeLabel()
Definition: alice-desktop-1.3.pyw:12521
alice-desktop-1.UpdateFreqTrace
def UpdateFreqTrace()
Definition: alice-desktop-1.3.pyw:13399
alice-desktop-1.onCanvasFreqLeftClick
def onCanvasFreqLeftClick(event)
Definition: alice-desktop-1.3.pyw:17707
alice-desktop-1.DoFFT
def DoFFT()
Definition: alice-desktop-1.3.pyw:13406
alice-desktop-1.Digital_RC_High_Pass
def Digital_RC_High_Pass(InBuff, TC1, Gain)
Digital RC filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3.pyw:4916
alice-desktop-1.onCanvasBdSnap
def onCanvasBdSnap(event)
Definition: alice-desktop-1.3.pyw:18089
alice-desktop-1.Settingsscroll
def Settingsscroll(event)
Definition: alice-desktop-1.3.pyw:22717
alice-desktop-1.BuildAWGBoxCarB
def BuildAWGBoxCarB()
Definition: alice-desktop-1.3.pyw:21556
alice-desktop-1.BOffsetA
def BOffsetA(event)
Definition: alice-desktop-1.3.pyw:3218
alice-desktop-1.onAWGBkey
def onAWGBkey(event)
Definition: alice-desktop-1.3.pyw:18168
alice-desktop-1.onMulXScroll
def onMulXScroll(event)
Definition: alice-desktop-1.3.pyw:22611
alice-desktop-1.SchroederPhase
def SchroederPhase(Length, NrTones, Ampl)
Definition: alice-desktop-1.3.pyw:10017
alice-desktop-1.UpdateAwgContRet
def UpdateAwgContRet(temp)
Definition: alice-desktop-1.3.pyw:12708
alice-desktop-1.CheckMathString
def CheckMathString()
Check Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2585
alice-desktop-1.VBtoggle
def VBtoggle()
Definition: alice-desktop-1.3.pyw:15806
alice-desktop-1.BgColor
def BgColor()
Toggle the Background and text colors based on ColorMode.
Definition: alice-desktop-1.3.pyw:1990
alice-desktop-1.UpdateNiCTrace
def UpdateNiCTrace()
Definition: alice-desktop-1.3.pyw:15779
alice-desktop-1.ETSUpdate
def ETSUpdate()
Definition: alice-desktop-1.3.pyw:22633
alice-desktop-1.MakeMuxModeWindow
def MakeMuxModeWindow()
Definition: alice-desktop-1.3.pyw:18648
alice-desktop-1.BShowCurvesAllBP
def BShowCurvesAllBP()
Definition: alice-desktop-1.3.pyw:13357
font
alice-desktop-1.SelfCalibration
def SelfCalibration()
Definition: alice-desktop-1.3.pyw:19947
alice-desktop-1.BTriggerMode
def BTriggerMode()
place holder for future hardware triggering if implemented
Definition: alice-desktop-1.3.pyw:2746
alice-desktop-1.onRetDigFiltB
def onRetDigFiltB(event)
Definition: alice-desktop-1.3.pyw:21416
alice-desktop-1.Bsamples2
def Bsamples2()
Definition: alice-desktop-1.3.pyw:13133
alice-desktop-1.BuildAWGBoxCarA
def BuildAWGBoxCarA()
Definition: alice-desktop-1.3.pyw:21530
alice-desktop-1.BStart
def BStart()
Start aquaring scope time data.
Definition: alice-desktop-1.3.pyw:2976
alice-desktop-1.onCanvasBodeClickScroll
def onCanvasBodeClickScroll(event)
Definition: alice-desktop-1.3.pyw:17927
alice-desktop-1.Blevel1BP
def Blevel1BP()
Definition: alice-desktop-1.3.pyw:13300
alice-desktop-1.MakeNicPlot
def MakeNicPlot()
Definition: alice-desktop-1.3.pyw:15583
alice-desktop-1.AWGAMakeAMSine
def AWGAMakeAMSine()
Definition: alice-desktop-1.3.pyw:10601
alice-desktop-1.DestroyETSScreen
def DestroyETSScreen()
Definition: alice-desktop-1.3.pyw:22583
alice-desktop-1.AWGAMakeFourier
def AWGAMakeFourier()
Definition: alice-desktop-1.3.pyw:10716
alice-desktop-1.MakeGenericSerialWindow
def MakeGenericSerialWindow()
Definition: alice-desktop-1.3.pyw:21127
alice-desktop-1.UpdateAwgCont
def UpdateAwgCont()
Definition: alice-desktop-1.3.pyw:12698
alice-desktop-1.AWGBLoadCSV
def AWGBLoadCSV()
Definition: alice-desktop-1.3.pyw:11727
alice-desktop-1.RExecuteFromString
def RExecuteFromString(temp)
Definition: alice-desktop-1.3.pyw:21739
alice-desktop-1.BuildBoxCarA
def BuildBoxCarA()
Definition: alice-desktop-1.3.pyw:21398
alice-desktop-1.MakePhAScreen
def MakePhAScreen()
Definition: alice-desktop-1.3.pyw:16249
alice-desktop-1.BAWGAPhaseDelay
def BAWGAPhaseDelay()
Definition: alice-desktop-1.3.pyw:10218
alice-desktop-1.BAWGBFreq
def BAWGBFreq(temp)
Definition: alice-desktop-1.3.pyw:11595
alice-desktop-1.IACaresize
def IACaresize(event)
Definition: alice-desktop-1.3.pyw:15224
alice-desktop-1.DestroyOOTwindow
def DestroyOOTwindow()
Definition: alice-desktop-1.3.pyw:23395
alice-desktop-1.CreateToolTip.widget
widget
Definition: alice-desktop-1.3.pyw:880
alice-desktop-1.MakeTimeScreen
def MakeTimeScreen()
Update the time screen with traces and text
Definition: alice-desktop-1.3.pyw:7332
alice-desktop-1.onAWGAkey
def onAWGAkey(event)
Definition: alice-desktop-1.3.pyw:18162
alice-desktop-1.BTriggerEdge
def BTriggerEdge()
Function no longer used.
Definition: alice-desktop-1.3.pyw:2699
alice-desktop-1.AWGBMakeFourier
def AWGBMakeFourier()
Definition: alice-desktop-1.3.pyw:11858
alice-desktop-1.BAWGBDutyCycle
def BAWGBDutyCycle(temp)
Definition: alice-desktop-1.3.pyw:11666
alice-desktop-1.MakeOhmWindow
def MakeOhmWindow()
if askyesno("Flash Failed", "Failed to update firmware.\n Try again?"): try: session....
Definition: alice-desktop-1.3.pyw:22406
alice-desktop-1.onCanvasAverage
def onCanvasAverage(event)
Definition: alice-desktop-1.3.pyw:9667
alice-desktop-1.onCanvasSASix
def onCanvasSASix(event)
Definition: alice-desktop-1.3.pyw:17853
alice-desktop-1.STOREcsvfile
def STOREcsvfile()
Definition: alice-desktop-1.3.pyw:16988
alice-desktop-1.BAbout
def BAbout()
Show info on software / firmware / hardware.
Definition: alice-desktop-1.3.pyw:2215
alice-desktop-1.MakeMeasureScreen
def MakeMeasureScreen()
Definition: alice-desktop-1.3.pyw:21854
alice-desktop-1.BrownNoise
def BrownNoise(N, mag)
Definition: alice-desktop-1.3.pyw:9985
alice-desktop-1.BUserBMeas
def BUserBMeas()
Ask user for channel B Measurement Label and Formula.
Definition: alice-desktop-1.3.pyw:2394
alice-desktop-1.MakeMinigenWindow
def MakeMinigenWindow()
Make AD983x based DDS generator screen.
Definition: alice-desktop-1.3.pyw:20591
alice-desktop-1.DestroySpectrumScreen
def DestroySpectrumScreen()
Definition: alice-desktop-1.3.pyw:19637
alice-desktop-1.onCanvasSAFour
def onCanvasSAFour(event)
Definition: alice-desktop-1.3.pyw:17839
alice-desktop-1.sel2
def sel2(temp)
Definition: alice-desktop-1.3.pyw:5861
alice-desktop-1.Save_Cal_file
def Save_Cal_file()
Definition: alice-desktop-1.3.pyw:20414
alice-desktop-1.NqPCaresize
def NqPCaresize(event)
Definition: alice-desktop-1.3.pyw:15489
alice-desktop-1.BHozPoss
def BHozPoss(event)
Definition: alice-desktop-1.3.pyw:2783
alice-desktop-1.onCanvasXYRightClick
def onCanvasXYRightClick(event)
Definition: alice-desktop-1.3.pyw:9691
alice-desktop-1.BStepSync
def BStepSync()
Definition: alice-desktop-1.3.pyw:18936
alice-desktop-1.BSendGS
def BSendGS()
Definition: alice-desktop-1.3.pyw:20973
alice-desktop-1.onCanvasTwo
def onCanvasTwo(event)
Definition: alice-desktop-1.3.pyw:9599
alice-desktop-1.MakeDA1Window
def MakeDA1Window()
Make window to control PMOD DA1 board.
Definition: alice-desktop-1.3.pyw:20766
alice-desktop-1.CreateToolTip.waittime
waittime
Definition: alice-desktop-1.3.pyw:878
alice-desktop-1.FindRisingEdge
def FindRisingEdge(Trace1, Trace2)
Routine to find rising edge of traces.
Definition: alice-desktop-1.3.pyw:5318
alice-desktop-1.onCanvasBodeLeftClick
def onCanvasBodeLeftClick(event)
Definition: alice-desktop-1.3.pyw:17947
alice-desktop-1.SetXYVAPoss
def SetXYVAPoss()
Definition: alice-desktop-1.3.pyw:2926
alice-desktop-1.onCanvasSAThree
def onCanvasSAThree(event)
Definition: alice-desktop-1.3.pyw:17832
alice-desktop-1.IASourceSet
def IASourceSet()
Set up IA AWG sources.
Definition: alice-desktop-1.3.pyw:3067
alice-desktop-1.AWGBMakeTrapazoid
def AWGBMakeTrapazoid()
Definition: alice-desktop-1.3.pyw:12117
alice-desktop-1.BShowCurvesNone
def BShowCurvesNone()
Turn off display of all time waveforms.
Definition: alice-desktop-1.3.pyw:2689
alice-desktop-1.sel0
def sel0(temp)
Definition: alice-desktop-1.3.pyw:5795
alice-desktop-1.onCanvasSANine
def onCanvasSANine(event)
Definition: alice-desktop-1.3.pyw:17871
alice-desktop-1.Bnot
def Bnot()
Definition: alice-desktop-1.3.pyw:12772
alice-desktop-1.onAWGAscroll
def onAWGAscroll(event)
Definition: alice-desktop-1.3.pyw:18113
alice-desktop-1.onCanvasBodeRightClick
def onCanvasBodeRightClick(event)
Definition: alice-desktop-1.3.pyw:17915
alice-desktop-1.BStartOhm
def BStartOhm()
Definition: alice-desktop-1.3.pyw:3032
alice-desktop-1.BDBdiv1BP
def BDBdiv1BP()
Definition: alice-desktop-1.3.pyw:13336
alice-desktop-1.DestroyPhAScreen
def DestroyPhAScreen()
Definition: alice-desktop-1.3.pyw:16016
alice-desktop-1.onCanvasBdFour
def onCanvasBdFour(event)
Definition: alice-desktop-1.3.pyw:18049
alice-desktop-1.BDBdiv1
def BDBdiv1()
Definition: alice-desktop-1.3.pyw:13154
alice-desktop-1.BRoll
def BRoll()
Toggel on/off Roll Sweep Mode.
Definition: alice-desktop-1.3.pyw:3130
alice-desktop-1.AWGAMakeSinc
def AWGAMakeSinc()
Definition: alice-desktop-1.3.pyw:10752
alice-desktop-1.SetXYVBPoss
def SetXYVBPoss()
Definition: alice-desktop-1.3.pyw:2932
alice-desktop-1.MakePhAWindow
def MakePhAWindow()
Definition: alice-desktop-1.3.pyw:15831
alice-desktop-1.UnWrap
def UnWrap(InArray, WrFactor)
Definition: alice-desktop-1.3.pyw:10044
alice-desktop-1.ConnectDevice
def ConnectDevice()
Definition: alice-desktop-1.3.pyw:21982
alice-desktop-1.DestroyGenericSerialScreen
def DestroyGenericSerialScreen()
Definition: alice-desktop-1.3.pyw:21219
alice-desktop-1.Blevel2
def Blevel2()
Definition: alice-desktop-1.3.pyw:13085
alice-desktop-1.SelectBoard
def SelectBoard()
temp = 0 print "read ADM1177 controler" print devx.ctrl_transfer( 0xa0, 0x17, 0, 0,...
Definition: alice-desktop-1.3.pyw:22012
alice-desktop-1.BodeCheckBox
def BodeCheckBox()
Definition: alice-desktop-1.3.pyw:3293
alice-desktop-1.SetIBPoss
def SetIBPoss()
Definition: alice-desktop-1.3.pyw:2920
alice-desktop-1.BSaveCal
def BSaveCal()
Save gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.pyw:2286
alice-desktop-1.SettingsTextKey
def SettingsTextKey(event)
Definition: alice-desktop-1.3.pyw:22721
alice-desktop-1.onCanvasZero
def onCanvasZero(event)
Definition: alice-desktop-1.3.pyw:9648
alice-desktop-1.DigPotShiftOut
def DigPotShiftOut(DValue)
Definition: alice-desktop-1.3.pyw:20823
alice-desktop-1.CreateToolTip.id
id
Definition: alice-desktop-1.3.pyw:885
alice-desktop-1.BStopBP
def BStopBP()
Definition: alice-desktop-1.3.pyw:13278
alice-desktop-1.BSaveData
def BSaveData()
Save scope all time array data to file.
Definition: alice-desktop-1.3.pyw:2097
alice-desktop-1.onTextKeyAWG
def onTextKeyAWG(event)
Definition: alice-desktop-1.3.pyw:18174
alice-desktop-1.BHelp
def BHelp()
Open User Guide in Browser open a URL, in this case, the ALICE desk-top-users-guide.
Definition: alice-desktop-1.3.pyw:2210
alice-desktop-1.BAWGSync
def BAWGSync()
Definition: alice-desktop-1.3.pyw:12732
alice-desktop-1.BAWGAShape
def BAWGAShape()
Definition: alice-desktop-1.3.pyw:10265
alice-desktop-1.BSetFmin
def BSetFmin()
Definition: alice-desktop-1.3.pyw:23232
alice-desktop-1.Analog_Phase_In
def Analog_Phase_In()
Definition: alice-desktop-1.3.pyw:3707
alice-desktop-1.BLoadConfigSA
def BLoadConfigSA()
Load confirfuration from SA window button.
Definition: alice-desktop-1.3.pyw:1894
alice-desktop-1.BCHBlevel
def BCHBlevel()
Definition: alice-desktop-1.3.pyw:3196
alice-desktop-1.UpdateBodeAll
def UpdateBodeAll()
Definition: alice-desktop-1.3.pyw:13371
alice-desktop-1.onCanvasBdNine
def onCanvasBdNine(event)
Definition: alice-desktop-1.3.pyw:18081
alice-desktop-1.Ohm_Analog_In
def Ohm_Analog_In()
Ohmmeter loop.
Definition: alice-desktop-1.3.pyw:3516
alice-desktop-1.UpdateXYTrace
def UpdateXYTrace()
Update XY trace and screen.
Definition: alice-desktop-1.3.pyw:5969
alice-desktop-1.DestroyBoardScreen
def DestroyBoardScreen()
Definition: alice-desktop-1.3.pyw:21976
alice-desktop-1.BStopSA
def BStopSA()
Definition: alice-desktop-1.3.pyw:13049
alice-desktop-1.donothing
def donothing()
Nop.
Definition: alice-desktop-1.3.pyw:2673
alice-desktop-1.ApplyMathYString
def ApplyMathYString()
Apply Y Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2656
alice-desktop-1.Blevel4BP
def Blevel4BP()
Definition: alice-desktop-1.3.pyw:13327
alice-desktop-1.MakeDigFiltWindow
def MakeDigFiltWindow()
Make screen for applying digital filters.
Definition: alice-desktop-1.3.pyw:21226
alice-desktop-1.AWGAMakeImpulse
def AWGAMakeImpulse()
Definition: alice-desktop-1.3.pyw:11138
alice-desktop-1.onCanvasNine
def onCanvasNine(event)
Definition: alice-desktop-1.3.pyw:9643
alice-desktop-1.BLoadAWGFiltB
def BLoadAWGFiltB()
Definition: alice-desktop-1.3.pyw:21616
alice-desktop-1.AWGAReadWAV
def AWGAReadWAV()
Definition: alice-desktop-1.3.pyw:10376
alice-desktop-1.AWGAMakeUGNoise
def AWGAMakeUGNoise()
Definition: alice-desktop-1.3.pyw:11239
alice-desktop-1.BLoadCal
def BLoadCal()
Load gain, offset and filter variables for external dividers.
Definition: alice-desktop-1.3.pyw:2358
alice-desktop-1.BSaveScreenIA
def BSaveScreenIA()
Save IA canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2063
alice-desktop-1.DestroyDA1Screen
def DestroyDA1Screen()
Destroy PMOD DA1 screen.
Definition: alice-desktop-1.3.pyw:20817
alice-desktop-1.BuildRejectFilter
def BuildRejectFilter(Order, Freject, Fsample)
Definition: alice-desktop-1.3.pyw:21657
alice-desktop-1.DestroyOhmScreen
def DestroyOhmScreen()
Definition: alice-desktop-1.3.pyw:22476
alice-desktop-1.BLoadConfigTime
def BLoadConfigTime()
Load confirfuration from Scope window button.
Definition: alice-desktop-1.3.pyw:1906
alice-desktop-1.onCanvasLeftArrow
def onCanvasLeftArrow(event)
Move Time curcors left 1 or 5.
Definition: alice-desktop-1.3.pyw:9196
alice-desktop-1.Write_WAV
def Write_WAV(data, repeat, filename)
Definition: alice-desktop-1.3.pyw:10061
alice-desktop-1.MakeDacScreen
def MakeDacScreen()
Make the DAC interface screen
Definition: alice-desktop-1.3.pyw:5927
alice-desktop-1.BTriglevel
def BTriglevel(event)
evalute trigger level entry string to a numerical value and set new trigger level
Definition: alice-desktop-1.3.pyw:2758
alice-desktop-1.AWGBMakePWMSine
def AWGBMakePWMSine()
Definition: alice-desktop-1.3.pyw:11962
alice-desktop-1.ETSCheckBox
def ETSCheckBox()
Definition: alice-desktop-1.3.pyw:3346
alice-desktop-1.DestroyNqPScreen
def DestroyNqPScreen()
Definition: alice-desktop-1.3.pyw:15482
alice-desktop-1.BSTOREtraceBP
def BSTOREtraceBP()
Definition: alice-desktop-1.3.pyw:12860
alice-desktop-1.BSetMarkerLocation
def BSetMarkerLocation()
Ask user for new Marker text location on screen.
Definition: alice-desktop-1.3.pyw:2663
alice-desktop-1.BAWGBAmpl
def BAWGBAmpl(temp)
Definition: alice-desktop-1.3.pyw:11518
alice-desktop-1.CreateToolTip.unschedule
def unschedule(self)
Un-schedule Action.
Definition: alice-desktop-1.3.pyw:899
alice-desktop-1.MakeAD5626Window
def MakeAD5626Window()
Make Controls for AD5626 serial DAC.
Definition: alice-desktop-1.3.pyw:21047
alice-desktop-1.onCanvasBdFive
def onCanvasBdFive(event)
Definition: alice-desktop-1.3.pyw:18056
alice-desktop-1.onCanvasTrising
def onCanvasTrising(event)
Definition: alice-desktop-1.3.pyw:9653
alice-desktop-1.onCanvasFreqRightClick
def onCanvasFreqRightClick(event)
Definition: alice-desktop-1.3.pyw:17676
alice-desktop-1.onCanvasShowPdBcur
def onCanvasShowPdBcur(event)
Definition: alice-desktop-1.3.pyw:18106
alice-desktop-1.BlueNoise
def BlueNoise(N, mag)
Definition: alice-desktop-1.3.pyw:9969
alice-desktop-1.BAWGAFreq
def BAWGAFreq(temp)
Definition: alice-desktop-1.3.pyw:10175
alice-desktop-1.BCHAlevel
def BCHAlevel()
Definition: alice-desktop-1.3.pyw:3174
alice-desktop-1.MakeIATrace
def MakeIATrace()
Definition: alice-desktop-1.3.pyw:14723
alice-desktop-1.IAtoggle
def IAtoggle()
Definition: alice-desktop-1.3.pyw:15814
alice-desktop-1.BOffsetB
def BOffsetB(event)
Definition: alice-desktop-1.3.pyw:3242
alice-desktop-1.onCanvasClickRight
def onCanvasClickRight(event)
Definition: alice-desktop-1.3.pyw:9058
alice-desktop-1.BSaveMuxData
def BSaveMuxData()
Save External Mux data to file.
Definition: alice-desktop-1.3.pyw:2110
alice-desktop-1.AddAWGBNoise
def AddAWGBNoise()
Definition: alice-desktop-1.3.pyw:12671
alice-desktop-1.SyncImage
def SyncImage()
Definition: alice-desktop-1.3.pyw:18903
alice-desktop-1.DoNothing
def DoNothing(event)
Another Nop.
Definition: alice-desktop-1.3.pyw:2676
alice-desktop-1.IACapReset
def IACapReset()
Definition: alice-desktop-1.3.pyw:15451
alice-desktop-1.BCSVfile
def BCSVfile()
Definition: alice-desktop-1.3.pyw:12905
alice-desktop-1.onStopBodeScroll
def onStopBodeScroll(event)
Definition: alice-desktop-1.3.pyw:22237
alice-desktop-1.BSaveScreenBP
def BSaveScreenBP()
Save Bode canvas as encapsulated postscript file.
Definition: alice-desktop-1.3.pyw:2080
alice-desktop-1.MakeNiCScreen
def MakeNiCScreen()
Make the Nichols Plot screen.
Definition: alice-desktop-1.3.pyw:15626
alice-desktop-1.BAWGBShape
def BAWGBShape()
Definition: alice-desktop-1.3.pyw:11685
alice-desktop-1.AWGANumCycles
def AWGANumCycles()
Definition: alice-desktop-1.3.pyw:10362
alice-desktop-1.DestroySampleRate
def DestroySampleRate()
Definition: alice-desktop-1.3.pyw:22163
alice-desktop-1.DigPotSend
def DigPotSend(Temp)
Definition: alice-desktop-1.3.pyw:20858
alice-desktop-1.DestroyDigFiltScreen
def DestroyDigFiltScreen()
Definition: alice-desktop-1.3.pyw:21441
alice-desktop-1.ReSetBIGO
def ReSetBIGO()
Definition: alice-desktop-1.3.pyw:23264
alice-desktop-1.CreateToolTip.configure
def configure(self, text)
Re Configure text string.
Definition: alice-desktop-1.3.pyw:927
alice-desktop-1.PinkNoise
def PinkNoise(N, mag)
Definition: alice-desktop-1.3.pyw:9954
alice-desktop-1.CreateToolTip.enter
def enter(self, event=None)
Action when mouse enters.
Definition: alice-desktop-1.3.pyw:888
alice-desktop-1.AWGAMakeTrapazoid
def AWGAMakeTrapazoid()
Definition: alice-desktop-1.3.pyw:10870
alice-desktop-1.BSaveDataIA
def BSaveDataIA()
Definition: alice-desktop-1.3.pyw:12979
alice-desktop-1.AWGBMakePulse
def AWGBMakePulse()
Definition: alice-desktop-1.3.pyw:12182
alice-desktop-1.MakeDigScreen
def MakeDigScreen()
Make the Digital I/O screen.
Definition: alice-desktop-1.3.pyw:5709
alice-desktop-1.onCanvasDownArrow
def onCanvasDownArrow(event)
Move Vertical cursors down 1 or 5.
Definition: alice-desktop-1.3.pyw:9154
alice-desktop-1.sel1
def sel1(temp)
Definition: alice-desktop-1.3.pyw:5828
alice-desktop-1.Analog_Freq_In
def Analog_Freq_In()
Main SA and Bode loop Read from the stream and store the data into the arrays.
Definition: alice-desktop-1.3.pyw:4971
alice-desktop-1.BHoldOff
def BHoldOff(event)
Set Hold off time from entry widget.
Definition: alice-desktop-1.3.pyw:2772
alice-desktop-1.CreateToolTip.__init__
def __init__(self, widget, text='widget info')
create a tooltip for a given widget
Definition: alice-desktop-1.3.pyw:877
alice-desktop-1.INITIALIZEstart
def INITIALIZEstart()
Definition: alice-desktop-1.3.pyw:17540
alice-desktop-1.BStartBP
def BStartBP()
Definition: alice-desktop-1.3.pyw:13175
alice-desktop-1.IACapZero
def IACapZero()
Definition: alice-desktop-1.3.pyw:15444
alice-desktop-1.onCanvasSAZero
def onCanvasSAZero(event)
Definition: alice-desktop-1.3.pyw:17875
alice-desktop-1.AWGAMakeUUNoise
def AWGAMakeUUNoise()
Definition: alice-desktop-1.3.pyw:11194
alice-desktop-1.BAWGBPhase
def BAWGBPhase(temp)
Definition: alice-desktop-1.3.pyw:11648
alice-desktop-1.BUserFFTwindow
def BUserFFTwindow()
Definition: alice-desktop-1.3.pyw:17645
alice-desktop-1.SetScaleMuxC
def SetScaleMuxC()
Definition: alice-desktop-1.3.pyw:2878
alice-desktop-1.AWGBMakeMath
def AWGBMakeMath()
Definition: alice-desktop-1.3.pyw:11824
alice-desktop-1.onCanvasSAOne
def onCanvasSAOne(event)
Definition: alice-desktop-1.3.pyw:17818
alice-desktop-1.onTextKey
def onTextKey(event)
Definition: alice-desktop-1.3.pyw:18179
alice-desktop-1.onAD5626Scroll
def onAD5626Scroll(event)
Definition: alice-desktop-1.3.pyw:21117
alice-desktop-1.onCanvasFive
def onCanvasFive(event)
Definition: alice-desktop-1.3.pyw:9623
alice-desktop-1.SetMuxCPoss
def SetMuxCPoss()
Definition: alice-desktop-1.3.pyw:2842
alice-desktop-1.SetMuxAPoss
def SetMuxAPoss()
Analog Mux buttons.
Definition: alice-desktop-1.3.pyw:2830
alice-desktop-1.BCHAIlevel
def BCHAIlevel()
Definition: alice-desktop-1.3.pyw:3185
alice-desktop-1.BodeCaresize
def BodeCaresize(event)
Definition: alice-desktop-1.3.pyw:18927
alice-desktop-1.BAWGAOffset
def BAWGAOffset(temp)
Definition: alice-desktop-1.3.pyw:10137
alice-desktop-1.VioletNoise
def VioletNoise(N, mag)
Definition: alice-desktop-1.3.pyw:10001
alice-desktop-1.BUserAMeas
def BUserAMeas()
Ask user for channel A Measurement Label and Formula.
Definition: alice-desktop-1.3.pyw:2377
alice-desktop-1.UpdateXYScreen
def UpdateXYScreen()
Update XY screen with trace and text.
Definition: alice-desktop-1.3.pyw:5974
alice-desktop-1.BLoadConfigIA
def BLoadConfigIA()
Load confirfuration from IA window button.
Definition: alice-desktop-1.3.pyw:1888
alice-desktop-1.onCanvasXYScrollClick
def onCanvasXYScrollClick(event)
Definition: alice-desktop-1.3.pyw:9700
alice-desktop-1.onCanvasSAPeak
def onCanvasSAPeak(event)
Definition: alice-desktop-1.3.pyw:17885
alice-desktop-1.CreateToolTip.text
text
Definition: alice-desktop-1.3.pyw:881
alice-desktop-1.BPeakholdmode
def BPeakholdmode()
Definition: alice-desktop-1.3.pyw:12799
alice-desktop-1.PhACheckBox
def PhACheckBox()
Definition: alice-desktop-1.3.pyw:3320
alice-desktop-1.onCanvasShowPcur
def onCanvasShowPcur(event)
Definition: alice-desktop-1.3.pyw:17908
alice-desktop-1.onCanvasBdTwo
def onCanvasBdTwo(event)
Definition: alice-desktop-1.3.pyw:18035
alice-desktop-1.onCanvasClickLeft
def onCanvasClickLeft(event)
Definition: alice-desktop-1.3.pyw:9321
alice-desktop-1.AWGAMakeBodeSine
def AWGAMakeBodeSine()
Definition: alice-desktop-1.3.pyw:10463
alice-desktop-1.BTrigger50p
def BTrigger50p()
Set Trigger level to 50% (mid) point of current waveform.
Definition: alice-desktop-1.3.pyw:2705
alice-desktop-1.BAWGAAmpl
def BAWGAAmpl(temp)
Definition: alice-desktop-1.3.pyw:10097
alice-desktop-1.onCanvasSAEight
def onCanvasSAEight(event)
Definition: alice-desktop-1.3.pyw:17867
alice-desktop-1.CreateToolTip.wraplength
wraplength
Definition: alice-desktop-1.3.pyw:879
alice-desktop-1.MakePhATrace
def MakePhATrace()
Definition: alice-desktop-1.3.pyw:16048
alice-desktop-1.AWGBMakeBodeSine
def AWGBMakeBodeSine()
Definition: alice-desktop-1.3.pyw:11893
messagebox
alice-desktop-1.MakeBodeTrace
def MakeBodeTrace()
Definition: alice-desktop-1.3.pyw:14094
alice-desktop-1.SetVAPoss
def SetVAPoss()
Definition: alice-desktop-1.3.pyw:2902
alice-desktop-1.onDigFiltBScroll
def onDigFiltBScroll(event)
Definition: alice-desktop-1.3.pyw:21419
alice-desktop-1.ApplyMathXString
def ApplyMathXString()
Apply X Math string from entry widget.
Definition: alice-desktop-1.3.pyw:2649
alice-desktop-1.onAWGFiltAScroll
def onAWGFiltAScroll(event)
Definition: alice-desktop-1.3.pyw:21526
alice-desktop-1.UpdateAWGWin
def UpdateAWGWin()
Definition: alice-desktop-1.3.pyw:23029
alice-desktop-1.onCanvasBdZero
def onCanvasBdZero(event)
Definition: alice-desktop-1.3.pyw:18085
alice-desktop-1.AWGAReadFile
def AWGAReadFile()
Definition: alice-desktop-1.3.pyw:10296
alice-desktop-1.BSavePhAData
def BSavePhAData()
Definition: alice-desktop-1.3.pyw:16896
alice-desktop-1.DestroyIAScreen
def DestroyIAScreen()
Definition: alice-desktop-1.3.pyw:15430
alice-desktop-1.Analog_Roll_time
def Analog_Roll_time()
Definition: alice-desktop-1.3.pyw:3924
alice-desktop-1.CreateToolTip.leave
def leave(self, event=None)
Action when mouse leaves.
Definition: alice-desktop-1.3.pyw:891
alice-desktop-1.DestroyBodeScreen
def DestroyBodeScreen()
Definition: alice-desktop-1.3.pyw:19305
alice-desktop-1.UpdatePotSlider
def UpdatePotSlider()
Definition: alice-desktop-1.3.pyw:20899
alice-desktop-1.onCanvasBdThree
def onCanvasBdThree(event)
Definition: alice-desktop-1.3.pyw:18042
alice-desktop-1.ReSetAGO
def ReSetAGO()
Definition: alice-desktop-1.3.pyw:23240
alice-desktop-1.onRetDigFiltA
def onRetDigFiltA(event)
Definition: alice-desktop-1.3.pyw:21391
alice-desktop-1.UpdateFreqAll
def UpdateFreqAll()
Definition: alice-desktop-1.3.pyw:13388
alice-desktop-1.AWGAMakeMath
def AWGAMakeMath()
Definition: alice-desktop-1.3.pyw:10429
alice-desktop-1.onCanvasUpArrow
def onCanvasUpArrow(event)
Move Vertical cursors up 1 or 5.
Definition: alice-desktop-1.3.pyw:9112
alice-desktop-1.UpdatePhATrace
def UpdatePhATrace()
Definition: alice-desktop-1.3.pyw:16039
alice-desktop-1.onStopfreqScroll
def onStopfreqScroll(event)
Definition: alice-desktop-1.3.pyw:22217
alice-desktop-1.BAWGFiltAMath
def BAWGFiltAMath()
Definition: alice-desktop-1.3.pyw:21599
alice-desktop-1.DestroyMeasureScreen
def DestroyMeasureScreen()
Definition: alice-desktop-1.3.pyw:21921
alice-desktop-1.BLoadAWGFiltA
def BLoadAWGFiltA()
Definition: alice-desktop-1.3.pyw:21575
alice-desktop-1.BShowCurvesNoneSA
def BShowCurvesNoneSA()
Definition: alice-desktop-1.3.pyw:12782
alice-desktop-1.onDigFiltAScroll
def onDigFiltAScroll(event)
Definition: alice-desktop-1.3.pyw:21394
alice-desktop-1.SetScaleMuxB
def SetScaleMuxB()
Definition: alice-desktop-1.3.pyw:2866
alice-desktop-1.XYcaresize
def XYcaresize(event)
Definition: alice-desktop-1.3.pyw:19646
alice-desktop-1.TimeCheckBox
def TimeCheckBox()
set check box colors
Definition: alice-desktop-1.3.pyw:3266
alice-desktop-1.BShowCurvesAll
def BShowCurvesAll()
Set to display all time waveforms.
Definition: alice-desktop-1.3.pyw:2679
alice-desktop-1.BDFiltBMath
def BDFiltBMath()
Definition: alice-desktop-1.3.pyw:21508
alice-desktop-1.BLoadDFiltA
def BLoadDFiltA()
Definition: alice-desktop-1.3.pyw:21447
alice-desktop-1.AWGBMakeImpulse
def AWGBMakeImpulse()
Definition: alice-desktop-1.3.pyw:12381
alice-desktop-1.DestroyMathScreen
def DestroyMathScreen()
Destroy New Math waveform controls menu window.
Definition: alice-desktop-1.3.pyw:2578
alice-desktop-1.CALCFFTwindowshape
def CALCFFTwindowshape()
Definition: alice-desktop-1.3.pyw:17556
alice-desktop-1.ReMakeAWGwaves
def ReMakeAWGwaves()
Re Make the current selected AWG waveform buffers.
Definition: alice-desktop-1.3.pyw:1761
alice-desktop-1.BDBdiv2BP
def BDBdiv2BP()
Definition: alice-desktop-1.3.pyw:13346
alice-desktop-1.BIOffsetA
def BIOffsetA(event)
Definition: alice-desktop-1.3.pyw:3230
alice-desktop-1.AWGAMakeRamp
def AWGAMakeRamp()
Definition: alice-desktop-1.3.pyw:11007
alice-desktop-1.BDBdiv2
def BDBdiv2()
Definition: alice-desktop-1.3.pyw:13164
alice-desktop-1.CheckMathXString
def CheckMathXString()
Check X Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2604
alice-desktop-1.BShowCurvesNoneBP
def BShowCurvesNoneBP()
Definition: alice-desktop-1.3.pyw:13364
alice-desktop-1.AWGAMakeSSQ
def AWGAMakeSSQ()
Definition: alice-desktop-1.3.pyw:10810
alice-desktop-1.MakeSampleRateMenu
def MakeSampleRateMenu()
Definition: alice-desktop-1.3.pyw:22102
alice-desktop-1.AWGBLoadWAV
def AWGBLoadWAV()
Definition: alice-desktop-1.3.pyw:11792
alice-desktop-1.SetXYIBPoss
def SetXYIBPoss()
Definition: alice-desktop-1.3.pyw:2944
alice-desktop-1.onCanvasEight
def onCanvasEight(event)
Definition: alice-desktop-1.3.pyw:9638
alice-desktop-1.Blevel3
def Blevel3()
Definition: alice-desktop-1.3.pyw:13094
alice-desktop-1.AWGAMakeFMSine
def AWGAMakeFMSine()
Definition: alice-desktop-1.3.pyw:10527
alice-desktop-1.onCanvasSeven
def onCanvasSeven(event)
Definition: alice-desktop-1.3.pyw:9633
alice-desktop-1.BSaveConfigBP
def BSaveConfigBP()
Save current configuration from Bode window.
Definition: alice-desktop-1.3.pyw:1562
alice-desktop-1.FindTriggerSample
def FindTriggerSample(TrgBuff)
Find the sample where trigger event happened.
Definition: alice-desktop-1.3.pyw:5480
alice-desktop-1.BAWGAPhase
def BAWGAPhase(temp)
Definition: alice-desktop-1.3.pyw:10228
alice-desktop-1.BSaveConfigIA
def BSaveConfigIA()
Save current configuration from IA window.
Definition: alice-desktop-1.3.pyw:1550
alice-desktop-1.MakeTimeTrace
def MakeTimeTrace()
Make the scope time traces.
Definition: alice-desktop-1.3.pyw:5979
alice-desktop-1.onCanvasThree
def onCanvasThree(event)
Definition: alice-desktop-1.3.pyw:9607
alice-desktop-1.BStartSA
def BStartSA()
Definition: alice-desktop-1.3.pyw:13006
alice-desktop-1.BUserCustomPlotText
def BUserCustomPlotText()
Ask user to enter custom plot label string.
Definition: alice-desktop-1.3.pyw:2412
alice-desktop-1.BStop
def BStop()
Stop (pause) scope tool.
Definition: alice-desktop-1.3.pyw:3083
alice-desktop-1.onCanvasBdSix
def onCanvasBdSix(event)
Definition: alice-desktop-1.3.pyw:18063
alice-desktop-1.BSendMG
def BSendMG()
Send serial data to DDS board.
Definition: alice-desktop-1.3.pyw:20559
alice-desktop-1.BSaveChannelData
def BSaveChannelData()
Save selected scope time array data to file.
Definition: alice-desktop-1.3.pyw:2124
alice-desktop-1.onCanvasSAFive
def onCanvasSAFive(event)
Definition: alice-desktop-1.3.pyw:17846
alice-desktop-1.UpdateIATrace
def UpdateIATrace()
Definition: alice-desktop-1.3.pyw:14671
alice-desktop-1.VABtoggle
def VABtoggle()
Definition: alice-desktop-1.3.pyw:15798
alice-desktop-1.CreateToolTip.showtip
def showtip(self, event=None)
Display Tip Text.
Definition: alice-desktop-1.3.pyw:905
alice-desktop-1.onCanvasSix
def onCanvasSix(event)
Definition: alice-desktop-1.3.pyw:9628
alice-desktop-1.DestroyMinigenScreen
def DestroyMinigenScreen()
Destroy DDS board sacrren.
Definition: alice-desktop-1.3.pyw:20671
alice-desktop-1.UpdateNqPTrace
def UpdateNqPTrace()
Definition: alice-desktop-1.3.pyw:15760
alice-desktop-1.onCanvasShowFcur
def onCanvasShowFcur(event)
Definition: alice-desktop-1.3.pyw:17894
alice-desktop-1.UpdateMeasureScreen
def UpdateMeasureScreen()
Definition: alice-desktop-1.3.pyw:21821
alice-desktop-1.onCanvasShowVcur
def onCanvasShowVcur(event)
Definition: alice-desktop-1.3.pyw:9683
alice-desktop-1.SetAD9833
def SetAD9833(temp)
Definition: alice-desktop-1.3.pyw:20529
alice-desktop-1.BSaveScreenSA
def BSaveScreenSA()
Definition: alice-desktop-1.3.pyw:12755
alice-desktop-1.MakeDigPotWindow
def MakeDigPotWindow()
set up controls for single, dual or quad, digital pots
Definition: alice-desktop-1.3.pyw:20916
alice-desktop-1.onCanvasShowTcur
def onCanvasShowTcur(event)
Definition: alice-desktop-1.3.pyw:9675
alice-desktop-1.AWGBMakeUUNoise
def AWGBMakeUUNoise()
Definition: alice-desktop-1.3.pyw:12436
alice-desktop-1.Analog_Time_In
def Analog_Time_In()
Scope time main loop Read the analog data and store the data into the arrays.
Definition: alice-desktop-1.3.pyw:3638
alice-desktop-1.BSnapShotXY
def BSnapShotXY()
Take snap shot of displayed XY Traces.
Definition: alice-desktop-1.3.pyw:2266
alice-desktop-1.AWGBConfigMath
def AWGBConfigMath()
Definition: alice-desktop-1.3.pyw:11846
alice-desktop-1.Wrap
def Wrap(InArray, WrFactor)
Definition: alice-desktop-1.3.pyw:10030
alice-desktop-1.onCanvasRightArrow
def onCanvasRightArrow(event)
Move Time curcors right 1 or 5.
Definition: alice-desktop-1.3.pyw:9238
alice-desktop-1.onCanvasFour
def onCanvasFour(event)
Definition: alice-desktop-1.3.pyw:9615
alice-desktop-1.onCanvasSAReset
def onCanvasSAReset(event)
Definition: alice-desktop-1.3.pyw:17888
alice-desktop-1.BSTOREtraceSA
def BSTOREtraceSA()
Definition: alice-desktop-1.3.pyw:12825
alice-desktop-1.XYCheckBox
def XYCheckBox()
Definition: alice-desktop-1.3.pyw:3273
alice-desktop-1.time_points_from_freq
def time_points_from_freq(freq, fs=1, density=False)
Definition: alice-desktop-1.3.pyw:9903
alice-desktop-1.onAWGFiltBScroll
def onAWGFiltBScroll(event)
Definition: alice-desktop-1.3.pyw:21552
alice-desktop-1.Digital_RC_Low_Pass
def Digital_RC_Low_Pass(InBuff, TC1, Gain)
Digital filter function for input divider frequency compensation TC1 is in micro seconds.
Definition: alice-desktop-1.3.pyw:4937
alice-desktop-1.BLoadDFiltB
def BLoadDFiltB()
Definition: alice-desktop-1.3.pyw:21485
alice-desktop-1.UpdateBodeTrace
def UpdateBodeTrace()
Definition: alice-desktop-1.3.pyw:13379
alice-desktop-1.SetChopMuxMode
def SetChopMuxMode()
Definition: alice-desktop-1.3.pyw:18874
alice-desktop-1.DestroyDigPotScreen
def DestroyDigPotScreen()
Definition: alice-desktop-1.3.pyw:20967
alice-desktop-1.BNormalmode
def BNormalmode()
Definition: alice-desktop-1.3.pyw:12789
alice-desktop-1.onCanvasTfalling
def onCanvasTfalling(event)
Definition: alice-desktop-1.3.pyw:9658
alice-desktop-1.UpdateAWGA
def UpdateAWGA()
Definition: alice-desktop-1.3.pyw:11307
alice-desktop-1.NiCCaresize
def NiCCaresize(event)
Definition: alice-desktop-1.3.pyw:15616
ttk
alice-desktop-1.MakeSettingsMenu
def MakeSettingsMenu()
Definition: alice-desktop-1.3.pyw:22725
alice-desktop-1.BSnapShot
def BSnapShot()
Take snap shot of displayed time waveforms.
Definition: alice-desktop-1.3.pyw:2235
alice-desktop-1.AWGALoadCSV
def AWGALoadCSV()
Definition: alice-desktop-1.3.pyw:10304
alice-desktop-1.AddAWGANoise
def AddAWGANoise()
Definition: alice-desktop-1.3.pyw:11440
alice-desktop-1.SPIShiftOut
def SPIShiftOut(DValue)
========== MiniGen routines ========== SPI shift output routine
Definition: alice-desktop-1.3.pyw:20507
alice-desktop-1.CreateToolTip
Tool Tip Ballon help stuff.
Definition: alice-desktop-1.3.pyw:875
alice-desktop-1.onCanvasSANormal
def onCanvasSANormal(event)
Definition: alice-desktop-1.3.pyw:17882
alice-desktop-1.UpdateNqPScreen
def UpdateNqPScreen()
Definition: alice-desktop-1.3.pyw:15765
alice-desktop-1.DestroyCommandScreen
def DestroyCommandScreen()
Definition: alice-desktop-1.3.pyw:21733
alice-desktop-1.OhmCheckBox
def OhmCheckBox()
Definition: alice-desktop-1.3.pyw:3333
alice-desktop-1.BAWGAModeLabel
def BAWGAModeLabel()
Definition: alice-desktop-1.3.pyw:11284
alice-desktop-1.AWGAConfigMath
def AWGAConfigMath()
Definition: alice-desktop-1.3.pyw:10451
alice-desktop-1.ToggleAWGBPhaseDelay
def ToggleAWGBPhaseDelay()
Definition: alice-desktop-1.3.pyw:11626
alice-desktop-1.onCanvasClickScroll
def onCanvasClickScroll(event)
Shift Time or vertical cursors if on or shift gated measurement cursors if enabled.
Definition: alice-desktop-1.3.pyw:9067
alice-desktop-1.onFminScroll
def onFminScroll(event)
Definition: alice-desktop-1.3.pyw:22605
alice-desktop-1.onSrateScroll
def onSrateScroll(event)
Definition: alice-desktop-1.3.pyw:22170
alice-desktop-1.CheckMathYString
def CheckMathYString()
Check Y Math String for syntac errors.
Definition: alice-desktop-1.3.pyw:2623
alice-desktop-1.BLoadConfigBP
def BLoadConfigBP()
Load confirfuration from Bode window button.
Definition: alice-desktop-1.3.pyw:1900
alice-desktop-1.SetDualMuxMode
def SetDualMuxMode()
Definition: alice-desktop-1.3.pyw:18844
alice-desktop-1.MakeBoardScreen
def MakeBoardScreen()
Definition: alice-desktop-1.3.pyw:21927
alice-desktop-1.SetMuxDPoss
def SetMuxDPoss()
Definition: alice-desktop-1.3.pyw:2848
alice-desktop-1.onTextScroll
def onTextScroll(event)
Definition: alice-desktop-1.3.pyw:18129
alice-desktop-1.AWGAWriteFile
def AWGAWriteFile()
Definition: alice-desktop-1.3.pyw:10423
alice-desktop-1.Blevel3BP
def Blevel3BP()
Definition: alice-desktop-1.3.pyw:13318
alice-desktop-1.SetADC_Mux
def SetADC_Mux()
Definition: alice-desktop-1.3.pyw:22257
alice-desktop-1.CreateToolTip.schedule
def schedule(self)
Sehedule Action.
Definition: alice-desktop-1.3.pyw:895
alice-desktop-1.AWGBNumCycles
def AWGBNumCycles()
Definition: alice-desktop-1.3.pyw:11504
alice-desktop-1.IBtoggle
def IBtoggle()
Definition: alice-desktop-1.3.pyw:15822
alice-desktop-1.MakeBodeScreen
def MakeBodeScreen()
Definition: alice-desktop-1.3.pyw:14339
alice-desktop-1.UpdateXYAll
def UpdateXYAll()
Update Data, trace and XY screen.
Definition: alice-desktop-1.3.pyw:5964
alice-desktop-1.FreqCheckBox
def FreqCheckBox()
Definition: alice-desktop-1.3.pyw:3280
alice-desktop-1.DestroyXYScreen
def DestroyXYScreen()
Definition: alice-desktop-1.3.pyw:19936
alice-desktop-1.BSaveConfig
def BSaveConfig(filename)
Save current configureation to file.
Definition: alice-desktop-1.3.pyw:933
alice-desktop-1.UpdateFreqScreen
def UpdateFreqScreen()
Definition: alice-desktop-1.3.pyw:13403
alice-desktop-1.AWGBMakeSSQ
def AWGBMakeSSQ()
Definition: alice-desktop-1.3.pyw:12058
alice-desktop-1.FreqCaresize
def FreqCaresize(event)
Definition: alice-desktop-1.3.pyw:19315
alice-desktop-1.BSaveConfigSA
def BSaveConfigSA()
Save current configuration from SA window.
Definition: alice-desktop-1.3.pyw:1556
alice-desktop-1.AWGBReadFile
def AWGBReadFile()
Definition: alice-desktop-1.3.pyw:11719
alice-desktop-1.UpdateTimeScreen
def UpdateTimeScreen()
Update time screen with trace and text.
Definition: alice-desktop-1.3.pyw:5959
alice-desktop-1.UpdateIAAll
def UpdateIAAll()
Definition: alice-desktop-1.3.pyw:14661
alice-desktop-1.UpdateIAScreen
def UpdateIAScreen()
Definition: alice-desktop-1.3.pyw:14675
alice-desktop-1.DestroyAWGScreen
def DestroyAWGScreen()
Definition: alice-desktop-1.3.pyw:18641
alice-desktop-1.NewEnterMathControls
def NewEnterMathControls()
Make New Math waveform controls menu window.
Definition: alice-desktop-1.3.pyw:2423
alice-desktop-1.MakeIAScreen
def MakeIAScreen()
Draw the impedance Analyzer screen.
Definition: alice-desktop-1.3.pyw:14849
alice-desktop-1.SetIAPoss
def SetIAPoss()
Definition: alice-desktop-1.3.pyw:2914
alice-desktop-1.MakeXYTrace
def MakeXYTrace()
Make the XY plot traces.
Definition: alice-desktop-1.3.pyw:7057
alice-desktop-1.onCanvasXYLeftClick
def onCanvasXYLeftClick(event)
Definition: alice-desktop-1.3.pyw:9722
alice-desktop-1.CreateToolTip.hidetip
def hidetip(self)
Hide Tip Action.
Definition: alice-desktop-1.3.pyw:921
alice-desktop-1.BExecuteFromString
def BExecuteFromString()
Definition: alice-desktop-1.3.pyw:21743
alice-desktop-1.onCanvasBdEight
def onCanvasBdEight(event)
Definition: alice-desktop-1.3.pyw:18077
alice-desktop-1.BShowCurvesAllSA
def BShowCurvesAllSA()
Definition: alice-desktop-1.3.pyw:12775
alice-desktop-1.Analog_Fast_time
def Analog_Fast_time()
Definition: alice-desktop-1.3.pyw:4164
alice-desktop-1.onMiniGenScroll
def onMiniGenScroll(event)
Definition: alice-desktop-1.3.pyw:20677
alice-desktop-1.TimeSeriesSingleTone
def TimeSeriesSingleTone(n, BinNum, Fsample, mag)
Definition: alice-desktop-1.3.pyw:9943
alice-desktop-1.onCanvasShowBPcur
def onCanvasShowBPcur(event)
Definition: alice-desktop-1.3.pyw:18092
alice-desktop-1.PhACaresize
def PhACaresize(event)
Definition: alice-desktop-1.3.pyw:16025
alice-desktop-1.UpdatePhAAll
def UpdatePhAAll()
Definition: alice-desktop-1.3.pyw:16034
alice-desktop-1.BuildBoxCarB
def BuildBoxCarB()
Definition: alice-desktop-1.3.pyw:21423
alice-desktop-1.sel3
def sel3(temp)
Definition: alice-desktop-1.3.pyw:5894
alice-desktop-1.UpdatePhAScreen
def UpdatePhAScreen()
Definition: alice-desktop-1.3.pyw:16043